From: Jim Weirich Date: 2002-08-16T21:46:25+09:00 Subject: Re: Thought question: Where does "new" come from? >>>>> "mikkelf" == mikkelfj-anti-spam writes: mikkelf> The "problem" (if it is a problem) I have with "class mikkelf> method" is that any normally defined method belongs to mikkelf> the class, as opposed to singleton methods that belongs mikkelf> to the instance. Hence I see the normal methods as class mikkelf> methods. The "static" methods belongs to a separate mikkelf> default created instance with the same name as the mikkelf> class. This default instance is statically allocated at mikkelf> the time the class is first defined. Hence the term mikkelf> static method. Normally defined methods are called instance methods. Their definitions are held by the class object, but they are only applicable to instances of that class. Class methods (what you call static) are methods that are applicable to the class. class A def imethod() end def A.cmethod() end end A.instance_methods #=> ["imethod"] A.methods #=> ["cmethod", "new", "superclass", "private_instance_methods", "clone", ... ] The term "static" is misleading. Static (as used in Java and C++) refers to stand-alone functions that are in the scope of a class, but can be invoked without any reference to an object instance. No such thing exists in Ruby. -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)