s = Proc.new {|x|x*2} puts "proc:" + (s.call(5)).to_s def foo(&a) a.call(5) end foo{|x| puts "foo:" + (x*3).to_s} Running this program produces the output:
proc:10 foo:15 How does the value 3 from the foo block get passed to the proc? I expected this output:
proc:10 foo:10 The proc is always called with the value 5 as the argument because foo is defined as:
a.call(5) Why is foo 15 in the output?