Block Arguments

Learn how blocks can accept arguments.

Blocks make a lot of sense when passed to methods that are defined on collections like arrays and hashes.

Let’s look at some examples with arrays.

In our previous example that used the times method, our block didn’t accept an argument. A block that accepts an argument looks like this:

Create a free account to access the full course.

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