Ruby Closures for Dummies

Justyna Kuchta
Sep 24, 2019 · 6 min read
Photo by Allie on Unsplash

Blocks, procs, lambdas, and methods available in Ruby are collectively called closures.

Simply put, it’s all the variables referenced in the block that remain accessible for the life of the block even if defined in another scope. It can be defined in one scope and used in another. The best way to remember this is to imagine a closure as a little backpack that…