From: Robert Klemme Date: 2004-06-22T17:08:12+09:00 Subject: Re: A question about Class and Object "Sam Sungshik Kong" schrieb im Newsbeitrag news:paHBc.6843$_e1.3669@newssvr27.news.prodigy.com... > Hello! > > I found a strange thing. > > Object.class > =>Class > Class.class > =>Class > > As you see, Object and Class are of same type. > > Object.methods.length > =>73 > Class.methods.length > =>74 > Class.methods - Object.methods > =>["nesting"] > > I expected that Object has same methods as Class but it's not. > Can somebody explain and teach me please? There is also a general answer in Ruby: even if two instances belong to the same class they need not have the same number of methods, because methods can be defined on a per instance basis. Consider: irb(main):015:0> class Foo; def test; "test"; end; end => nil irb(main):016:0> f1 = Foo.new => # irb(main):017:0> f2 = Foo.new => # irb(main):018:0> class << f2; def test2; "test2"; end; end => nil irb(main):019:0> f1.class => Foo irb(main):020:0> f2.class => Foo irb(main):021:0> f1.methods.grep(/test/) => ["test"] irb(main):022:0> f2.methods.grep(/test/) => ["test2", "test"] irb(main):023:0> f2.methods - f1.methods => ["test2"] Regards robert