backend · easy
Block
An anonymous chunk of code passed to a method, often with `do…end` or `{…}`, invoked via `yield`.
Where you see it
Enumerables (`each`, `map`, `select`) are block-shaped. Methods like `File.open` yield a handle and close it afterward. Procs and lambdas are block-like objects you can store and pass.
Why it matters
Blocks are Ruby’s iterator and DSL superpower. Rails routes, validations, and jobs all read as “method plus a block.” Missing this makes every Ruby API look like magic.
Tags: ruby
