- Read Tutorial
- Watch Guide Video
- Complete the Exercise
Summary
Implement a method that can accept multiple blocks by leveraging lambdas.
Exercise Description
Build a method that takes multiple lambdas as arguments in order to illustrate how a single method can be passed multiple blocks as arguments.
Real World Usage
By default, a method in Ruby is limited to only receiving a single block as an argument. This is where lambdas (also known as closures in other languages) are able to extend the functionality of a single method. A method can take an unlimited number of lambdas as argument, so therefore lambdas allow you to give plain Ruby methods the ability to accept multiple blocks as arguments. This exercise helps to showcase this behavior by building a User tracking solution.