...

/

What are Blocks?

What are Blocks?

This lesson will tell you what blocks are and how do we use them in Ruby.

Like methods, but without a name

Blocks are one of the things programmers absolutely love about Ruby. They are an extremely powerful feature that allows us to write very flexible code. At the same time they read very well, and they are used all over the place.

So, what is a block?

Moreover, blocks can only be created by the way of passing them to a method when the method is called.

💡

A block is a piece of code that accepts arguments and returns a value. A block is always passed to a method call. ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy