Category:Elena: Difference between revisions

Line 205:
(m == 0)
! [ m / n ].
 
It is possible to use *if* template code :
 
if (m == 0)
[ n := n + 1. ];
[ n := m + n. ].
 
In this case the compiler always use optimized code for branching
 
Boolean symbols supports basic logical operations (AND, OR, XOR and NOT), so several conditions can be checked
 
if (aChar >= 48) and:(aChar < 58)
? [
theToken += aChar.
];
! [
Exception new:"Invalid expression" raise.
]
 
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
if ((x >= 0)and:[ array@x != 0] ?)
[
...
Line 225 ⟶ 233:
 
^ aBulls =>
-1 ? [ consoleEx writeLine:"Not a valid guess.". ^ true. ];
4 ? [
consoleEx writeLine:"Congratulations! You have won!".
^ false.
];
! [
theAttempt += 1.
Anonymous user