From: Rob Rypka Date: 2005-10-03T12:03:52+09:00 Subject: Re: class/singleton methods On 10/2/05, Mark Volkmann wrote: > These seem to be identical. Are they? > > class Foo > def Foo.bar > # some code > end > end > > class Foo > def self.bar > # some code > end > end They are identical. Inside Foo, self==Foo > If they are identical, is one form generally preferred over the other? I think it's more a matter of style. The advantage of using 'self' is that it always works with the class name (so you won't mess up cutting and pasting or changing the name of the class), but it's less clear what it does to others (you had to ask). > So a "class method" is the same as a "singleton method" on a Class object? Umm, yes? I'm not always sure what those terms refer to. I think reading this will help sort out your issues: http://www.rubygarden.org/ruby?ClassMethods -- Rob