Syntax
- if (condition) { ... }
- if (condition) { ... } else { ... }
- if (condition) { ... } else if (condition) { ... } else { ... }
- // Braces are optional for single line statements
if (condition) ... else if (condition) ... else ...
- switch (expression) { case pattern: ... default: ... }
- condition ? expression if true : expression if false;
All branching expressions make it possible to return evaluated expressions. This means branching results can be assigned to variables. In this case, all expressions that can be evaluated by a successful condition test must pass type unification. If no else
expression is given, the type is inferred to be Void
.