ELENA like Smalltalk does not support any special language constructs to implement the conditional branching. Instead special Boolean symbols (system’true and system’false) are used. All conditional operations should return these symbols as a result.
There are three branching methods :
then , then&else, else
Note that code in square brackets are in fact nested action classes ( an action class is a class supporting evaluate message). So this code is can be written in this form:
This expression can be written using special operators as well
Note: the main difference between using explicit messages and conditional operators is that the compiler may optimize the resulting code in the later case.
We could omit true or else part
Boolean symbols supports basic logical operations (AND, OR, XOR and NOT), so several conditions can be checked
Note that in this case both condition will be evaluated even if the first one is false. If we want to use short-circuit evaluation expression brackets should be used
A switch statement can be implemented using => operator