From: Brian Candler Date: 2008-11-04T22:41:17+09:00 Subject: Passing a block to a block I notice that if you pass a block to a block, you can't use 'yield' to yield to that block: $ cat yield_in_block.rb foo = lambda { |e| puts e } blk = lambda { |e| yield e } blk.call(123, &foo) $ ruby yield_in_block.rb yield_in_block.rb:2: no block given (LocalJumpError) from yield_in_block.rb:3 $ ruby19 yield_in_block.rb yield_in_block.rb:2:in `block in
': no block given (yield) (LocalJumpError) from yield_in_block.rb:3:in `call' from yield_in_block.rb:3:in `
' What's the reason for this? Does 'yield' only invoke the top-level block passed into a method? ruby1.9 is happy but only if I explicitly reference the block to yield. foo = lambda { |e| puts e } blk = lambda { |e,&y| y[e] } blk.call(123, &foo) Thanks, Brian. -- Posted via http://www.ruby-forum.com/.