December 2014
Intermediate to advanced
164 pages
2h 14m
English
CHAPTER 12
![]()
Blocks, Procs, and Lambdas
Some of the most powerful features of the Ruby language are closures, which are known as blocks, procs, and lambdas within Ruby. Closures within Ruby are also often misunderstood, mainly due to the flexibility when using them within Ruby.
A closure is in essence a function that can be stored as a variable; closures within Ruby are mainly used for iterating through data/result sets. Closures allow external access to local variables from within the closure.
Blocks
The simplest of the three closures is a block; this follows Ruby’s “normal” programming style. Blocks are simply “bits” of code that can be executed. ...
Read now
Unlock full access