From: Deepak Gole Date: 2008-07-07T13:47:27+09:00 Subject: Re: Basic ruby Question ------=_Part_439_14600150.1215406262312 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello stefano, Thanks for your explanation. On Fri, Jul 4, 2008 at 12:37 PM, Stefano Crocco wrote: > On Friday 04 July 2008, Deepak Gole wrote: > > Hello, > > > > I didn't understand the following concept. > > > > *class Universe > > > > private > > def self.private_method > > p "=========Hello world=======" > > end > > > > end > > > > Universe.**private_method** => "=========Hello world=======" > > * > > > > How come I get the o/p ( *"=========Hello world=======" * ) as I have > > declared that method as private. > > > > Thanks in advance > > Deepak Gole (DG) > > The private method only makes instance methods private, not class methods. > This means the reason you can call Universe.private_method is that, despite > its name, the method is still public. To make a class method private, you > can > use the Module#private_class_method method: > > class Universe > > def self.private_method > p "Hello world" > end > > private_class_method :private_method > > end > > Universe.private_method > > => private method `private_method' called for Universe:Class > (NoMethodError) > > I hope this helps > > Stefano > > > > ------=_Part_439_14600150.1215406262312--