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.
| RubyTalk
| RubyTalk
But if you are prepared to “cheat” and do something on the calling side,
I’ve used this explicit trick:
| RubyTalk
···
–
([ 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 )
Ptkwt1
16 January 2003 20:42
3
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