From: Robert Dober Date: 2008-12-14T19:55:45+09:00 Subject: Re: singleton methods vs. meta instance methods On Sat, Dec 13, 2008 at 10:50 PM, Brian Candler wrote: > Robert Dober wrote: >> I could however not see the difference between A and Object, can you >> explain please? > > The OP used an *instance* of class Object, not Object itself, and > compared it with class A, which is an instance of class Class. Brian I referred to exactly the same thing you do in your next post, just do a %s/Object/String/g. I did see his first point, although he did not give an example for the inconsistency. Confusing is it not ;) > > Perhaps it's clearer if written thus: > > obj = Object.new > obj_meta = (class << obj;self;end) > def obj.foobar; end > p obj.singleton_methods #=> ["foobar"] > p obj_meta.instance_methods(false) #=> ["foobar"] > > a = Class.new > a_meta = (class << a;self;end) > def a.foobar; end > p a.singleton_methods #=> ["foobar"] > p a_meta.instance_methods(false) #=> ["allocate", "superclass", > "foobar", "new"] No really I feel up to here we are just fine, the problem starts when we define something in the metaclass and see it in the singleton class, thus we can ask ourself how is it possible that we have the difference you showed in the last two lines. > > -- > 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