Repetition with Ruby

The Ruby method each allows you to iterate over a list of items. This is essentially a for-each style of loop and is like JavaScript’s each method. Notice that the iterative value is placed inside of two pipe (|) characters. You don’t have to put everything on one line. In fact, you can’t if you have multiple…

Break and Continue

We’ve seen the break in a switch statement. It stops running the blocks of code, and simple exits out of the switch. In the same manner, if you use a break in a loop, it exits us from the loop prematurely (not by the loop condition). The continue keyword moves us to the end of…