From: Lionel Thiry Date: 2005-04-06T00:09:43+09:00 Subject: Re: [EVALUATION] - E03b - The Ruby Object Model Ilias Lazaridis a �crit : > [snip] > I cannot access any of the metaclasses > > the same in the documentation: no metaclasses > > - > > Any suggestions / clarifications? > > . > Most of the time, everything goes in ruby as if there weren't any kind of metaclasses. For exemple, you cannot explicitely create your own metaclasses: class MyMetaClass < Class end It raises the exception: metaclass.rb:1: can't make subclass of Class (TypeError) Instead of thinking in metaclasses, everything goes as if you were asked to think in terms of singleton methods. (this has nothing to do with the Singleton Pattern) class MyClass def method puts "normal method" end def self.method puts "singleton method or metaclass method?" end end MyClass.new.method # => Normal method MyClass.method # => singleton method or metaclass method? p MyClass.singleton_methods # => ["method"] class Foo def test puts "instance method" end end foo = Foo.new foo.test # => instance method class << foo def test puts "singleton method" end end # singleton methods have precedence over instance method foo.test # => singleton method p foo.singleton_methods # => ["test"] -- Lionel Thiry