If Operator

if condition then operand1 [else operand2]

If the condition results in True, the result of the expression is the value of operand1. If not, the result of the expression is the value of operand2.

Note that operand2 is taken to be False if omitted. Note also that operand2 is not evaluated if the condition is True, and operand1 is not evaluated if the condition is False. For example, both these expressions result in 5:

  if True then 5 else func_that_loops_forever()
  if False then func_that_loops_forever() else 5

Herman Venter


This is Slim documentation as snarfed on 27 May 1999 by dB.