Learn
Blocks, Procs, and Lambdas
Why Procs?
Why bother saving our blocks as procs? There are two main advantages:
- Procs are full-fledged objects, so they have all the powers and abilities of objects. (Blocks do not.)
- Unlike blocks, procs can be called over and over without rewriting them. This prevents you from having to retype the contents of your block every time you need to execute a particular bit of code.
Instructions
1.
Check out the code in the editor. Woof, we had to rewrite that block a bunch of times! Remove the blocks and replace them with a proc called over_4_feet
so that the code in the block only needs to be written once.