From: Jeremy McAnally Date: 2008-04-14T11:54:14+09:00 Subject: Re: Executing class methods It's creating singleton methods. For example, you can do it on single objects: x = String.new def x.hello puts "Oh, hai." end x.hello # => Oh, hai. When doing ClassName.method, you're doing the same thing, only on a Class instance instead of a String instance of whatever. Now, you can do it with the same form as class << self too. For example, class << x def goodbye puts "Oh bai." end end x.goodbye # => Oh bai. In the case of class << self, self is a reference to the current class you're in. So, you're adding methods to the current Class instance. --Jeremy On Sun, Apr 13, 2008 at 9:49 PM, Clement Ow wrote: > Ron Fox wrote: > > As defined, archive is an instance method. > > > > try changing > > def archive > > > > to > > def self.archive > > > > or > > > > def MainLogic.archive > > > > To make it a class method. > Heesob Park wrote: > >class MainLogic > > class << self > > Yeah, it works. Thanks guys! But actually out of curiosity( i think it's > also good to know, so that I can help anyone on this forum in future,;), > what is it that self does? > Especially for class< > > > > -- > Posted via http://www.ruby-forum.com/. > > -- http://jeremymcanally.com/ http://entp.com Read my books: Ruby in Practice (http://manning.com/mcanally/) My free Ruby e-book (http://humblelittlerubybook.com/) Or, my blogs: http://mrneighborly.com http://rubyinpractice.com