Hi -- On Mon, 22 Aug 2005, Gavin Kistner wrote: > On Aug 21, 2005, at 9:04 AM, Alexandru Popescu wrote: >>> Sorry, I don't know Java (any more). Are you describing a global function >>> that is only available to instance methods of a certain class, which is >>> invoked without an explicit receiver? >>> >> >> Nope. I was talking about: >> [code] >> public class ExampleClass { >> public static void staticMethod() { >> // illegal access to any instance field >> System.out.println("staticMethod"); >> } >> } >> >> ExampleClass.staticMethod(); // prints the message; no instance of >> ExampleClass is available >> ExampleClass ec= new ExampleClass(); >> ec.staticMethod(); // prints the message; not recommended but works > > I don't know of a built-in mechanism to do this in Ruby, other than something > like: > > class Foo > def self.staticMethod > puts "staticMethod" > end > def staticMethod > self.class.staticMethod > end > end You could do: class C module M def x puts "'Static'? Nothing is 'static' in Ruby :-)" end end include M # for instances of C extend M # for C itself end C.x C.new.x David -- David A. Black dblack / wobblini.net