do_stuff = lambda do |&block|
puts "Object id is #{block.object_id}"
end
chain = lambda{}
do_stuff.call(&chain)
chain.instance_eval{}
do_stuff.call(&chain)
Prints out:
Block's object id is 2152284220
Block's object id is 2152284140
Using an equivalent method to do_stuff doesn't exhibit the same problem. Here's a complete example:
def stuff(&block)
puts "Object id is #{block.object_id}"
end
do_stuff = method(:stuff).to_proc
chain = lambda{}
stuff(&chain)
do_stuff.call(&chain)
chain.instance_eval{}
stuff(&chain)
do_stuff.call(&chain)
Object id is 2156158200
Object id is 2156158200
Object id is 2156158200
Object id is 2156157980