From: Piergiuliano Bossi Date: 2004-02-10T16:35:01+09:00 Subject: Re: evaluate and print an expression Bermejo, Rodrigo wrote: > > > def evaluate(code) > puts "#{code}==>" > eval code > end > > evaluate("1+2==3") > > 1+2==3 ==> > true :-) Ok, I understand that I haven't explained myself clearly. The point is not how to make it work with an expression as a String ("1+2==3" for example), but working directly with code. At the end the question is: is it possible to print the code of an expression? Remember that I'm trying to do something like this: irb(main):012:0> def evaluate(&code) irb(main):013:1> p code irb(main):014:1> code.call irb(main):015:1> end => nil irb(main):016:0> evaluate { 1+2==3 } # => true Instead of having: # I'd like to get: { 1+2==3 } or something like that. I think that the answer in ruby is: no, it's not possible. But I may be wrong. Ciao, Giuliano -- If you want to send me an email in the address you have to write 'p', then a dot, followed by 'bossi' at 'quinary', another dot and 'com' at last