From: Csaba Henk Date: 2005-02-19T16:24:45+09:00 Subject: Re: succint access to constants/class methods? On 2005-02-19, James Britt wrote: > This may not give you quite the answer you are looking for, but it may > help explain the behavior you are seeing: > > http://www.rubygarden.org/ruby?ClassMethodsTutorial Yes, I know class methods are just singleton methods of classes, thus it's quite clear that if I use A.foo then that message "foo" will be dispatched at A and nobody else. Contsants are more ambigouos. When you refer to the contsant C in an instance method just this way, writing a letter C, it's not specified explicitely whom should be the receiver. What you get by self.class::C is the desirable behaviour in the 99% of cases: thus C is visible from subclasses' instances as well, but can be overridden in a subclass. As one would expect in an object oriented environment. How many of you would disagree would disagree with the above paragraph? And how many of you uses self.class::C in her/his own code, rather than just the plain simple comfortable C? And it's such a stupid accident that the method which sets the right receiver just can't be used without the "self." prefix... Csaba