One of the main attractions (a least for me) of dynamic languages are their functional capabilities. Python has crippled lambdas but makes it up with very powerful stateful generators and generator expressions, even if its scoping rules are a bit fishy.
In comparison Ruby goes in the opposite direction. Being relatively poor on comprehension syntax it makes it up by offering 7 different ways to define a block of code and pass it around, with varying degrees of scoping. Unfortunately most of them appear to be nearly identical and are being kept around just to not break old code. Investigating this matter I found this enlightening sample script from Paul Cantrell:
This is quite a dizzing array of syntactic options, with subtle semantics differences that are not at all obvious, and riddled with minor special cases. It's like a big bear trap from programmers who expect the language to just work.
Paul explains how most of this mess grew out of lacking a formal specification for Ruby as a language, and how most of the ways to define a code block are equivalent and different at the same time. The final conclusion would be to use lambda if you want a true, lexically scoped first order function, and code blocks for everything else. The script finishes with a very cool lazy evaluation example and a pointer to the Lazy gem.
