A bit of a tangent: Ruby remains the most _pleasant_ programming language I've ever used, and I've come to the conclusion that it's in no small part due to blocks (and to a lesser extent due to the ease of metaprogramming, which ironically is also my biggest headache concerning Ruby).
Having to work on Puppet custom facts and functions I don't ever really feel like I've got a good understanding of what's going on under the covers with Ruby's meta-programming. And having blocks being a distinctly different thing from lambdas (and seemingly different from every other data type in the language) just makes it more confusing. Plus having blocks being passed as something that's not really a parameter(?) is just an extra complexity that wasn't really needed.
Ruby was the first non-PHP programming language I learned, and I used to love writing scripts in it, that I now write in Python instead, but the complexities outlined above kept me from ever wanting to write any complicated/large projects in it.
Recommend the now out-of-print book Metaprogramming Ruby to grant insight into the hows and whys of metaprogramming. Also serves as a decent intro to Ruby for intermediate coders. Criminal that you have to buy it on the secondary market now.
Blocks are just a convenient way to create and pass a proc. They aren’t a special data type.
Lambdas and procs are similar. The only real differences are that lambdas check to see if they have the correct number of arguments, and returning inside a lambda returns from the enclosing scope.
I like do describe it as ergonomics. It doesn’t really matter what I am doing, I generally enjoy doing it in Ruby. I also enjoy teaching using it. Students seem to pick up concepts very fast.
Rails uses I18n.locale as a "global variable" to store the locale of the request. Behind the scenes this is stored in Thread.current[]. So if you have a request that sets the locale to non-default one and you perform some work inside a lazy block, I18n.locale will return an incorrect value inside that block.
The equivalent of these is one of the things I was most happy about when I was working on GNU Smalltalk (I first added them to version 3.1 in 2008). Smalltalk already had iterators (which you created from collections with "readStream" and turned back into an array with "contents"), but no ability to filter, map or fold them. It is really, really useful.
Very cool. Does anybody know when this was added? I tried looking in the ruby doc but didn't see. That is one nice thing about javadocs in comparison. They usually say “since 1.6” or whatever.