From: Trans Date: 2008-03-15T04:49:15+09:00 Subject: Re: need for singleton_methods On Mar 14, 3:26 pm, Chinna Karuppan wrote: > I have trying to learn about this class< class< anything which will help this case.I can very well do it directly on the > class ... > class Foo > def Foo.bar > end > end > > what is the advantage I get by using the class << self notation... > > class Foo > class< def bar > end > end > end If you want to use a helper method, like #attr_accessor, for instance, this form becomes more convenient: class Foo class< This is all confusing .Can any body suggest a simple example with > tangible result to show the advantage.I am pretty sure more > people(nubies) will have this.... > > I have been doing my home work for the pass 2 days. I found that it is > helpful in inheritance as per the whytheluckystiff.com guy (why's > poignant guide)....I don't understand what is the need for even in that > case.If I define the method directly like this > > class Foo > def Foo.bar > end > end Better: class Foo def self.bar end end If you ever change then name of the module, you won't have to change it all over the place. T.