From: David Vallner Date: 2006-02-16T23:02:58+09:00 Subject: Re: Private methods - only available to oneself? Also, a minor mental exercise just came to mind. Presuming Ruby private would work like in C++, consider this code snippet: class A def foo puts "foo" end private :foo end a = A.new b = A.new def b.bar foo end Should this be valid? Is b an instance of the same class as a? If not, should the call to #foo still be valid or not? (E.g. should we consider singleton classes in the method access rules?) On a slightly related note, in case people watching the thread aren't confused enough as it is: Ruby's private methods are actually accessible from subclasses. In any case, I think determining anything based on the notion of "the same class" in Ruby would only lead to more ambiguity in the language rather than make it easier to comprehend. It would also seem very non-rubyish to me, since as opposed to the C++ language family, a class is not the only, or sometimes even not even an important element of defining an object's behaviour. David Vallner