I am using ruby 1.8.7.
p = lambda { return 10;}
def lab(block)
puts \'before\'
puts block.call
puts \'after\'
end
lab p
Above code output
I think you just need to dereference the block before you pass it:
foo = lambda { return 10 }
def trace_block(&fn)
puts 'before calling fn'
puts fn.call
puts 'after caling fn'
end
trace_block(&foo)
Output:
before calling fn
10
after caling fn
More info: