Ruby Snippet
Blocks, Procs, and Lambdas
Difficulty: Medium
Ruby has three closely related callable forms: blocks (one-shot, attached to a method call), `Proc` objects (named, non-strict about arity), and `Lambda` objects (named, strict about arity and `return` semantics). This snippet shows how each is constructed, when `yield` versus `&block` is appropriate, and the subtle differences in `return` and arity checking that decide which to use.
