Is it possible to get the same effect as the following, but without
having to pass self as an arguement?
def testMethod (calling_object)
This should output “AnotherClass”.
Do you need to know about the calling object or do you intend it to
do something for you ? Anyways…
I had a similar issue to solve recently and it seems that “block” &
eval() may help here:
def testMethod( &block )
r = my_test_result
puts eval( “self”, block).type # “self” where block was defined
rescue Exception ex; r = ex
block.call( r) # Callback to signal test result
TestClass.new.testMethod() do | r |
# Process test result r here
Warning: Not tested.
Depending on what you need, it is either the ability to get "self"
from a block or using a callback that may help you.
BTW: We are missing a caller() that would include bindings. With it
one could write: puts eval( “self”, caller( :Bindinds)).type; to
achieve exactly what you want.
At 03:44 07/06/2002 +0900, you wrote:
Phone: +33 (0) 4 92 27 74 17