As a suffix

An if can be written as an expression’s suffix:

  1. a = 2 if some_condition
  2. # The above is the same as:
  3. if some_condition
  4. a = 2
  5. end

This sometimes leads to code that is more natural to read.