Conditional Expressions

A conditional-expression has one of one of the following forms:

Copy
{ <expression> if <boolean-expression> [  <expression> if <boolean-expression>]* 
  <expression> otherwise }
 
{ if (<boolean-expression>) {[with-clause] <expression>} [
  else if (<boolean-expression>) {[with-clause] <expression>}]* 
  else {[with-clause] <expression>} }

Here expression must not be a conditional expression; nested conditional expressions are not allowed. See Expressions for information on other kinds of expressions.

Conditional expressions of the first form can contain a line break after a boolean-expression. Conditional expressions of the second form can contain a line break anywhere except within conjunctions or disjunctions (that is, except in between and/or clauses in a boolean-expression)

Each pair of curly braces within a conditional of the second form is optional in the absence of a with-clause.

A conditional expression evaluates to the value of the expression associated with the first boolean-expression that evaluates to true. If no boolean-expression evaluates to true, the conditional expression evaluates to the value of the expression associated with the otherwise or else.