CodeProject.TV will close July 31. Remember to ensure you’ve watched or download your videos! Full details here.

Ruby Programming: Blocks, Procs & Lambdas

17m 52s

Huw Collingbourne

Huw Collingbourne is a professional programmer, technology writer and instructor. He is Director of Technology at SapphireSteel Software (,... Read more

Blocks play an important role in Ruby programming – but they can be quite mystifying at the outset. This lesson cuts through the mystery to show how blocks, procs and lambdas are used.

Blocks in Ruby are like nameless methods or ‘lambda functions’. They are frequently used in Ruby when iterating or looping through collections of items. In this lesson, I explain what a block is and how to use it. We look at iterator methods to work with items from an array and we find out how to pass blocks to methods and execute blocks by calling or yielding them. If you are confused by blocks (and most newcomers to Ruby are!) this video will explain all you need to know to understand the fundamentals of blocks and how to use them in your code.