Learn
Blocks, Procs, and Lambdas
Why Procs?

Why bother saving our blocks as procs? There are two main advantages:

  1. Procs are full-fledged objects, so they have all the powers and abilities of objects. (Blocks do not.)
  2. 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.

Folder Icon

Take this course for free

Already have an account?