-
Notifications
You must be signed in to change notification settings - Fork 0
When Else
Sxtanna edited this page Jul 9, 2020
·
1 revision
when ('boolean expression') {
'passing expression'
} {else {
'failing expression'
}}
when
- When statements begin with the
when
keyword.
- boolean expression
- When statements evaluate whether the expression returns
true
orfalse
.
- passing expression
- When statements must contain a block of code to be executed in the case of the expression evaluating to
true
.
-
else
(optional)
- When statements can optionally contain a second
else
branch to be evaluated.
- failing expression
- The block of code to be executed in the case of the expression evaluating to
false
.
when (true) {
push "This will always be printed"
}
when (1 != 1) {
push "This will never be printed"
} else {
push "This will always be printed"
}