>>>>> "J" == Joel VanderWerf <vjoel / PATH.Berkeley.EDU> writes:

J> Why is the current class (meaning the place where def puts methods)
J> sometimes obtained by "self" and sometimes by "self.class"? Is there
J> some reliable way of determining where method definitions are going to
J> go? Or do you just have to know whether you're inside a "class ... end"
J> block? I'm confused.... as usual :)

 Well in ruby when you create a class, you must first create an instance to
 access the methods of this class.

 This is the same thing at toplevel, ruby first create an instance of
 Object to give you access to the methods of this class.

 What you are seeing is that a Class is just like any other objects, it has
 also a class, and this class is called the metaclass.


Guy Decoux