From: Robert Dober Date: 2006-08-21T00:31:27+09:00 Subject: Re: private and self ------=_Part_27730_3603969.1156087884548 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 8/20/06, Marinho Tobolla wrote: > > Why doesn=B4t the call with self doesn=B4t work ? I know that private mea= ns > private to the object, but the private methode call is within the same > object (at least it=B4s what i think). Doesn=B4t self mean "the object > himself" ? So why is this error occuring ? > Just quoting from the Pixcake (or was it Pickaxe ;) book [...] - *Private methods* cannot be called with an explicit receiver. Because you cannot specify an object when using them, private methods ca= n be called only in the defining class and by direct descendents within that = same object. The difference between ``protected'' and ``private'' is fairly subtle, and is different in Ruby than in most common OO languages. If a method is protected, it may be called by *any* instance of the defining class or its subclasses [...] So in Ruby surprisingly one canot indicate an explicit reveiver to a privat= e method. Even if it is self which comes to a surprise at the beginning. If I understand correctly this might change in Ruby2, and maybe ritefully s= o ;). Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_27730_3603969.1156087884548--