On Tue, Jul 31, 2001 at 01:46:30AM +0900, Minero Aoki wrote:
> You can. Try this:
> 
>   (class << some_class; self end).instance_methods

It works.... but I'm not sure that I understand why. Please tell me if my
assumptions are correct.

when I do:
class Foo
end

bar = Foo.new

bar_singleton = class << bar
	self
end

than bar_singleton will be an instance of class Class (and the superclass of
bar_singleton is Foo, altough due to the hiding of singleton classes, 
bar_singleton.superclass will tell return "Object").

and therefore

Foo_singleton = Foo_class << Foo
	self
end

will make Foo_singleton an instance of the "class of class Class" - and
therefore an instance of the metaclass of Foo.

And the instance method "instance_methods" of the
_metaclass_ gives me the class methods,
just like the instance method "instance_methods" of the
_class_ gives me the instance methods.


Is this correct? 

And why doens't Foo.class return the metaclass, just like foo.class returns
Foo?

greetings, and thanks for your help, Florian Pflug