On Aug 20, 2008, at 9:31 AM, Iñáki Baz Castillo wrote: > Hi, I know that I can extend a Class instance (an object) with a > method(s) by doing: > > object.extend Module > > but can I do it in a "inline" way without the need of a module? > I just want something as follows: > > time = Time.now > object.add_method 'def say_time(); return time; end' > > irb> object.say_time > --> time > You can do this with singleton methods: irb(main):001:0> object = Object.new => #<Object:0x304af8> irb(main):002:0> def object.say_time; Time.now; end => nil irb(main):003:0> object.say_time => Wed Aug 20 10:13:29 -0700 2008 -- Michael Granger <ged / FaerieMUD.org> Rubymage, Architect, Believer The FaerieMUD Consortium <http://www.FaerieMUD.org/>