if, unless
if/unless (expression) { statements } [ else { statements } ]
if/unless (expression) statement; else : statement
Executes statement or block after function name if parameter is true (for if) or false (for unless).
Indirect parameter passing is disabled
None
1
No. | Type | Description |
---|---|---|
1 input |
boolean | Boolean expression If the expression is true, then the following statement or block will be executed. Otherwise, it will be skipped. Default value: n/a |
none
for (a[] = 0, a[] <= 6, a[]++)
{
if ( even(a[])) echo(a[], " is even" );
unless ( a[] < 5 ) echo(a[], " is not smaller than 5" );
else: echo (a[], " is smaller than 5");
}
0 is even
0 is smaller than 5
1 is smaller than 5
2 is even
2 is smaller than 5
3 is smaller than 5
4 is even
4 is smaller than 5
5 is not smaller than 5
6 is even
6 is not smaller than 5