unless

An unless evaluates the then branch if its condition is falsey, and evaluates the else branch, if there’s any, otherwise. That is, it behaves in the opposite way of an if:

  1. unless some_condition
  2. then_expression
  3. else
  4. else_expression
  5. end
  6. # The above is the same as:
  7. if some_condition
  8. else_expression
  9. else
  10. then_expression
  11. end
  12. # Can also be written as a suffix
  13. close_door unless door_closed?