L
LAMBEAU Bernard
Ruby's documentation of instance_eval shows the "signature" of instance_eval as:
obj.instance_eval {| | block } => obj
I assume that the block should not take any argument. However, if I
write the following code:
class A
def sayhello(who)
puts "hello #{who}: #{object_id}"
end
end
A.new.instance_eval do |who|
sayhello("me")
who.sayhello("who")
end
it prints "hello me: -605850598" then "hello who: -605850598"
Is is guaranteed to work??
blambeau
obj.instance_eval {| | block } => obj
I assume that the block should not take any argument. However, if I
write the following code:
class A
def sayhello(who)
puts "hello #{who}: #{object_id}"
end
end
A.new.instance_eval do |who|
sayhello("me")
who.sayhello("who")
end
it prints "hello me: -605850598" then "hello who: -605850598"
Is is guaranteed to work??
blambeau