From: Just Another Victim of the Ambient Morality Date: 2006-07-20T17:15:32+09:00 Subject: What's the difference between these two block passing strategies? A common complaint I hear about Ruby is (I think, I may quoting incorrectly or the wrong thing) that "blocks aren't first order object." I won't pretend to know what that means but, in context, it appears that they are complaining about how you can't pass blocks around like variables. In particular, I recall someone having to deal with some kind of UI toolkit that requied blocks but couldn't pass the blocks up the call stack. I was just fiddling around with Ruby and I think I have two ways to do this and I was wondering if there were any subtle differences between them or any gatchas that I might be missing. Please take a look at them. Here's the first: def foo yield end def bar(&lambda) foo &lambda end bar { puts "Blocks!" } ...and here's the second: def foo yield end def bar foo { yield } end bar { puts "Blocks!" } ...so, what do you guys think? Are they equivalent? Is there a performance difference? Are they even doing what I think they're doing? Thank you...