By mswatcher
via patshaughnessy.net
Published: Sep 18 2012 / 18:20
Blocks are one of the most commonly used and powerful features of Ruby. As you probably know, they allow you to pass a code snippet to iterators such as each, detect or inject. You can also write your own functions that call blocks for other reasons using the yield keyword. Ruby code containing blocks is often more succinct, elegant and expressive than the equivalent code would appear in older languages such as C or Java.
Add your comment