By bloid
via redrobinsoftware.net
Published: Apr 26 2007 / 21:41
I expect that, if a language borrows a concept from another language, and if that language even uses the same name for the concept, the concept also has the same semantics. That is not the case for “private” access control in Ruby. In Java and C++, the sematics of the “private” access modifier for a method is: the method can only be called by methods of the class that declares the private method. In Ruby, the semantics is (taken from the pickaxe book, page 35): private methods can be called only in the context of the current object. A bit further in the book: The difference between “protected” and “private” is fairly subtle and is different in Ruby than in most common OO languages.





Add your comment