From: Eustaquio Rangel de Oliveira J Date: 2006-03-25T23:23:13+09:00 Subject: Object methods Hello there. :-) Ok, I know I can do this to add a method (and a class) to an object: irb(main):001:0> s = "Testing!" => "Testing!" irb(main):002:0> class < def says irb(main):004:2> puts "s says:"+self irb(main):005:2> end irb(main):006:1> end => nil irb(main):007:0> s.says s says:Testing! => nil irb(main):008:0> x = "Another test." => "Another test." irb(main):009:0> x.says NoMethodError: undefined method `says' for "Another test.":String from (irb):9 from :0 irb(main):010:0> My question is, dinamically, how to do that? Just like this: irb(main):010:0> x.class.class_eval %q(def x.says() puts "x says:"+self end) => nil irb(main):011:0> x.says x says:Another test. Or there is another shorter way to do that, with an object? To build an object method with some parameters like a string or a Proc? Thanks! :-) ---------------------------- Eust�quio "TaQ" Rangel eustaquiorangel@yahoo.com http://beam.to/taq Usu�rio GNU/Linux no. 224050