From: Paul Brannan Date: 2003-02-11T04:32:14+09:00 Subject: Re: everything is an object... right? On Tue, Feb 11, 2003 at 04:17:58AM +0900, Chris Pine wrote: > Hello, > > So everything in Ruby is an object, right? Classes are objects, etc. And > methods are objects, right? I think it would be more correct to say that all data in Ruby are objects. For example, "if" and other control structures are not objects. The stack is not an object. > My question: when I define a method, is a method object created right then? A method is created (and a Node that holds that method), but a Method object is not created. > Or is a method object only created when I call Object#method? If so, Yes. > objects of class Method really methods, or are they just objects associated > with those methods? They are callable objects (that is, they respond to the call() method). > If I redefine a method, does that change the original method object or make > a new one? If you redefine a method, the old method is replaced with the new one. But anyone who still has a reference to the old method still refers to the old method: irb(main):001:0> class Foo; def foo; puts 'foo!'; end; end => nil irb(main):002:0> f = Foo.new => # irb(main):003:0> m = f.method(:foo) => # irb(main):004:0> class Foo; def foo; puts 'bar!'; end; end => nil irb(main):005:0> m.call() foo! => nil Paul