From: Nikolai Weibull Date: 2009-02-24T00:48:50+09:00 Subject: [ruby-core:22371] Re: Surprising behavior in inheritance On Mon, Feb 23, 2009 at 16:03, Eero Saynatkari wrote: > Excerpts from Nikolai Weibull's message of Mon Feb 23 16:53:26 +0200 2009: >> Am I the only one surprised by this behavior? >> >> class A >> def a >> puts 'A#a' >> end >> protected :a >> end >> >> class B < A >> def a >> puts 'B#a' >> end >> end >> >> B.new.a # prints B#a >> >> I figured that B#a would be protected too. > You overrode the inherited method with a public one. Seems correct? Yes, that's perhaps what some would expect, but certainly not what I'd expect. I realize that the implementation is per method per class, as David pointed out, but it came as a surprise to me. I haven't found any documentation that describes how visibility and inheritance interact in this case.