...

/

What Are Blocks

What Are Blocks

Learn about blocks and how they are used.

Defining blocks

Blocks are likely one of Ruby’s most beloved and powerful features. They allow us to write very flexible code. They also read very well and are used all over the place. Moreover, blocks can only be created by the way of passing them to a method when the method is called.

So, what’s a block?

A block is a piece of code that accepts arguments and returns a ...