From: Robert Dober Date: 2008-12-14T20:35:33+09:00 Subject: Re: singleton methods vs. meta instance methods On Sun, Dec 14, 2008 at 12:16 PM, Brian Candler wrote: > This was demonstrated successfully, given the additional info that > metaclass.instance_methods(false) returns both the instance methods in > the metaclass plus the instance methods of the actual class. > > However, obj.singleton_methods returns only the instance methods in > obj.metaclass. Yes it comes down to this and hopefully you are right and I am wrong, because I am getting headaches already ;). But... alas you say that a meta.instance_methods returns both instance methods in the metaclass plus the instance methods of the actual class. I agree, you have shown this, however, :new, :allocate & :superclass are instance methods of the metaclass, not of the actual class, or are they not? This is for the example A {:meta=>["allocate", "answer", "new", "superclass"], :single=>["answer"], :name=>"A"} new is defined in class << A, no wait a moment it is not yet I guess I see the end of the light and the beginning of the tunnel def (A=Class::new).answer; 42 end def A.new; allocate end all_methods A {:meta=>["allocate", "almost", "answer", ***"new"***, "superclass"], :single=>["almost", "answer", ***"new"***], :name=>"A"} Great job Brian I got it, thanx. Cheers Robert > > At least, that's how I understand it at the moment - I am happy to be > corrected if this is wrong. > -- > Posted via http://www.ruby-forum.com/. > > -- Il computer non è una macchina intelligente che aiuta le persone stupide, anzi, è una macchina stupida che funziona solo nelle mani delle persone intelligenti. Computers are not smart to help stupid people, rather they are stupid and will work only if taken care of by smart people. Umberto Eco