SML# Document Version 3.7.1
19 Expressions

19.16 Conditional expression if exp1 then exp2 else exp3

This is for conditional branches. exp1 must be of bool type. The type of exp2 and exp3 must be same. Under these restrictions, this entire expression have the same type as exp2.

This is evaluated as follows. exp1 is evaluated at first. If its value is true, exp2 is evaluated and the resulting value is the value of the entire expression. Otherwise, exp3 is evaluated and the resulting value is the value of the entire expression.