Code Editor
Learn
Methods, Blocks, & Sorting

Blocks

Let's go over what we learned about blocks.

numbers = [5, 2, 8] sum = 0 numbers.each do |n| sum += n end puts sum

The example above is just a reminder about syntax. We calculate the sum of a list of numbers.

Report a Bug
If you see a bug or any other issue with this page, please report it here.