The else control structure executes a process and returns its value if a condition is true, otherwise if the condition is not true, the process is skipped over.
The else clause is used in succession with control structures to execute and return a process in the situation where the desired case is not reached:
- When the condition evaluates to false for the if clause
- When a loop does is not ended by a break statement
else clauses can be chained to handle cases not handled by previous else clauses
else clauses after a successful case will not be reached, except the nelse clause
The null value is returned when the last else clause fails
(1) else [condition1] : [process1]
(2) else : [process1]
(3) nelse [condition1] : [process1]
(4) nelse : [process1]
(1) The [condition1] value must be a bool, and when [condition1] is true, [process1] is executed and returned, otherwise the null value is returned
(2) Executes and returns [process1], added at the end of an else chain
(3) The [condition1] value must be a bool, and when [condition1] is true, or any of the previous if/else clauses succeed, executes and returns [process1].
(4) Executes and returns [process1] if any previous if/else clauses succeed