From: "christiantheilhave@..." Date: 2008-04-20T19:15:21+09:00 Subject: Re: Executing code in a variable On Apr 20, 11:43 am, Zangief Ief wrote: > Hello, > > I have a Ruby code stocked into a Ruby variable like this: > > buffer = ' puts "Hello World!" ' > > Is there a way for execute the current code by using buffer variable ? > > Thanks > -- > Posted viahttp://www.ruby-forum.com/. Sure, you can use eval, eg. irb(main):002:0> eval 'puts "Hello world"' Hello world => nil However, eval should be usually avoided. Instead Ruby has the methods instance_eval, class_eval and module_eval, which works the same as eval but the argumented is executed in the scope of the current object/ class/module. Regards, Christian