Using Unless
You may recall the alternative syntax for while loops mentioned in Chapter 5. Instead of writing this< while tired do sleep end
When an if test and the code to be executed are placed on separate lines, the then keyword is optional.
There will no doubt be occasions when you will need to take multiple different actions based on several alternative conditions.
Ruby also has a short-form notation for if..then..else in which a question mark ? replaces the if..then part and a colon : acts as else
Syntax
Test Condition ? if true do this : else do this
A simple test like this has only one of two possible results. Either a bit of code is run or it isn’t, depending on whether the test evaluates to true or not.
Be warned that Ruby’s Boolean operators can sometimes behave in a curious and unpredictable manner. For example:
puts( (not( 1==1 )) ) # This is ok