Where Do Ruby Blocks Come From?
Welcome, new subscribers! 👋 The launch of RUBY3.dev was a huge success, and I'm grateful for all the interest and positive feedback. This community rocks! 🤘
This week's article is titled Where Do Ruby Blocks Come From?
Blocks in Ruby are powerful, and they’re used everywhere. You can pass blocks implicitly to enumerable methods like map and select simply by adding { ... } or do ... end after the method name. You can explicitly create closures (aka anonymous functions) by using proc, lambda, or ->() semantics and pass them around as method arguments or store them as variables. Yes, blocks are pretty magical.
But we’re not here to talk about how to write blocks per se or what they’re good for. We’re here to talk about where they come from.