Reading the code passed inside a block?

Is it possible to read the code passed in a block, as, say, a String?
Or in any other way? That is, if I make a method call like:

reflector.superReflectiveMethod { |i| i >= 5 }

is there any way I could get output like

You passed in this code: “i >= 5”

Thanks in advance,

Francis

Francis Hwang wrote:

Is it possible to read the code passed in a block, as, say, a String?
Or in any other way? That is, if I make a method call like:

reflector.superReflectiveMethod { |i| i >= 5 }

is there any way I could get output like

You passed in this code: “i >= 5”

Thanks in advance,

Not really, AFAIK.
http://www.rubytalk.com/58063
http://www.rubytalk.com/58042

But if you are prepared to “cheat” and do something on the calling side,
I’ve used this explicit trick:
http://www.rubytalk.com/54588

···


([ Kent Dahl ]/)_ ~ [ http://www.stud.ntnu.no/~kentda/ ]/~
))_student
/(( _d L b_/ NTNU - graduate engineering - 5. year )
( __õ|õ// ) )Industrial economics and technological management(
_
/ö____/ (_engineering.discipline=Computer::Technology)

In article 7b561b93.0301161123.7b919add@posting.google.com,

···

Francis Hwang sera@fhwang.net wrote:

Is it possible to read the code passed in a block, as, say, a String?
Or in any other way? That is, if I make a method call like:

reflector.superReflectiveMethod { |i| i >= 5 }

is there any way I could get output like

You passed in this code: “i >= 5”

Thanks in advance,

Francis

Check out NodeDump here:
http://rubycentral.com/downloads/nodeDump.html

Also check out the link on that page to Guy Decoux’s ii.

Phil

"Or perhaps the truth is less interesting than the facts?"
Amy Weiss (accusing theregister.co.uk of engaging in ‘tabloid journalism’)
Senior VP, Communications
Recording Industry Association of America