March 22 - Demonstrate Ruby Procs / Lambdas vs Methods for Variable Scope
There are some key differences between procs / lambdas and traditional methods in Ruby, however the differences can many times be subtle. In this exercise we'll examine how variable scope is processed differently between the different options.
Guide Tasks
- Read Tutorial
- Watch Guide Video
- Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license
Already a Bottega Student? Sign In
Summary
Build a program that illustrates the differences in variable scope in Ruby between Procs / Lambdas, and traditional methods.
Exercise Description
Build a traditional method and a lambda or Proc and illustrate how the two processes have different access levels for local variables.
Real World Usage
This exercise showcases one of the subtle differences between Procs / lambdas and plain Ruby methods. At a high level it may seem like the three options can be used interchangeably, however in this guide we'll walk through how they approach variable access much differently.