From: John Date: 2006-07-12T00:50:05+09:00 Subject: Re: Some questions about serious Ruby development... Just Another Victim of the Ambient Morality wrote: > display evaluation results (like what IRB does) I use the following method to do that: def describe code # takes a string to be eval'ed and prints it along with showing the return value sep = ' => ' begin result = eval(code) puts code + sep + result.inspect return result rescue Exception => e puts code + sep + e.to_s return nil end end I then can issue the following to get a nice printout, and also get the returned value of the statement. Example: my_array = describe "Range.new(1, 5).to_a" Would output "Range.new(1, 5).to_a => [1, 2, 3, 4, 5]" and also assign my_array properly.