RbRuby · Lesson 3 of 11
Control Flow
Ruby's control flow reads like English prose. `unless` is `if not`. `until` is `while not`. You can put conditions at the end of a line. Matz really meant it about the happiness thing.
✦ Tip
Ruby has no `do...while`. The idiom is `loop do ... break if condition end`. Also: `case/when` is more powerful than most switch statements — it can match ranges, regexes, classes (via `===`), and arbitrary conditions.
Ruby has no `do...while`. The idiom is `loop do ... break if condition end`. Also: `case/when` is more powerful than most switch statements — it can match ranges, regexes, classes (via `===`), and arbitrary conditions.