0Pricing
Ruby Academy · Lesson

Blocks, Procs, and Lambdas

Understand how Ruby handles anonymous functions using blocks, Procs, and Lambdas.

1

Blocks, Procs, and Lambdas

Ruby provides powerful ways to handle reusable pieces of code using blocks, Procs, and Lambdas.

In this lesson, you will learn how to use these concepts effectively.

Blocks, Procs, and Lambdas — illustration 1

2

What is a Block?

A block is a piece of code enclosed between do ... end or curly braces { ... }.

[1, 2, 3].each do |num|
  puts num * 2
end

All lessons in this course

  1. Defining Methods
  2. Blocks, Procs, and Lambdas
  3. Yield and Passing Blocks
← Back to Ruby Academy