From: Pit Capitain Date: 2006-06-25T20:40:40+09:00 Subject: Re: class << self? Roger Johansson schrieb: > ... > what I dont get is why I only need to do the "class << self" thing when > aliasing static methods and not instance methods. Roger, I think you haven't gotten an answer to this part of your question yet. I'm sure you wouldn't expect the alias keyword at the instance level in order to create an alias for an instance method: class C def m ... end end c = C.new c.alias :mnew :m # create alias for the instance method C#m, # but only for the instance c, or for all # instances of C ??? So it makes sense to have the alias keyword where methods are normally defined: at the module/class level: class C def m ... end end class C alias :mnew :m # create alias for the instance method C#m end The same applies to singleton methods: o = Object.new class << o def m ... end end class << o alias :mnew :m # create alias for the singleton method o.m end The only difference to instance methods is that you can define singleton methods with an additional syntax: def o.m ... end Now, what you call "static methods" are simply singleton methods of class objects, so again the same mechanisms apply: C = Class.new class << C def m ... end end class << C alias :mnew :m # create alias for singleton method C.m end I've used the same syntax as in the example above to show the similarity to other singleton methods. Normally you'd write this as: class C class << self def m ... end end end class C class << self alias :mnew :m # create alias for singleton method C.m end end or, for the definition part, as: class C def self.m ... end end or even: def C.m ... end As others have noted, just forget about "static methods". They don't exist in Ruby. There are only instance methods and singleton methods, nothing more. Feel free to ask again if it's not clear. Regards, Pit