July 2011
Intermediate to advanced
400 pages
8h 46m
English
Incidentally, Ruby has two different syntaxes for testing Boolean (true/false) conditions. In the previous example, I’ve used the English-language style operators: and, or, and not. If you prefer, you could use alternative operators similar to those used in many other programming languages, namely, && (and), || (or), and ! (not).
Be careful, though: The two sets of operators aren’t completely interchangeable. For one thing, they have different precedence, which means that when multiple operators are used in a single test, the parts of the test may be evaluated in different orders depending on which operators you use. For example, look at this test:
days.rb
if aDay == 'Saturday' or aDay == 'Sunday' and not working_overtime daytype ...
Read now
Unlock full access