From: Sam Sungshik Kong Date: 2004-06-23T01:33:13+09:00 Subject: Re: A question about Class and Object Thank you! I was very close to it. And you assured me. Actually http://www.ruby-talk.org/104273 was in the thread that I started...:) I liked his explanation. Sam "George Marrows" wrote in message news:5e44d1a4.0406220019.47fdb543@posting.google.com... > "Sam Sungshik Kong" wrote > > > I'm using Ruby 1.8. > > > > Object.class.methods.length #->74 > > Object.methods.length #->73 > > > > Object.class is Class. > > Object is type of Class. > > > > I'm still confused with class and object and metaclass... > > Hi Sam -- > > The key is that what class an object is doesn't say everything about > what methods it has, because of the existence of singleton methods. > [And the list of methods an object has doesn't say everything about > what messages it responds to, because of the existence of > method_missing - though this is irrelevant to your question :)] James > Britt's recent message http://www.ruby-talk.org/104273 explains this, > though without mentioning singleton methods explicitly. > > In this case, the additional method ("nesting") is sneaking in as > singleton method on Module: > > irb(main):015:0> Module.singleton_methods > => ["constants", "nesting"] > > constants is also a Module singleton method, but nesting is the only > new one: > > irb(main):016:0> Object.methods.include?("nesting") > => false > irb(main):017:0> Object.methods.include?("constants") > => true > > .. hence the difference of 1 in the number of methods that Object and > Module have. > > Hope this helps, > > George.