From: Gennady Bystritsky Date: 2006-06-01T04:30:58+09:00 Subject: Re: class << self ...end - how does this create class methods? Pickaxe2 in chapter 24 on page 362 ("Classes and Objects") goes into great extend explaining the "class << object" feature, with "class << self" in particular. With pictures and good examples. It may be a good starting point. Hope it helps, Gennady. > -----Original Message----- > From: list-bounce@example.com > [mailto:list-bounce@example.com] On Behalf Of Wes Gamble > Sent: Wednesday, May 31, 2006 12:18 PM > To: ruby-talk ML > Subject: class << self ...end - how does this create class methods? > > I just ran into a seemingly weird problem until I discovered that the > method that I kept trying to call as an instance method was in fact a > class method. But of course, there isn't anything in the > signature to > indicate that to me. Apparently, if you do this: > > class << self > def x > end > end > > then x is a class method, not an instance method. > > I'm having trouble finding a good explanation of this in the Pickaxe > book - is someone willing to give me the low down. > > This appears to be the common idiom for defining class > methods and I'd > like to understand so I don't waste any more time. > > Thanks, > Wes > > -- > Posted via http://www.ruby-forum.com/. > >