if (condition-1) {
[ statements-1 ]
}
elsif (condition-2) {
[ statements-2 ]
}
else {
[ statements-3 ]
}
The elsif Statement
Syntax
An elsif
statement is used to evaluate a subsequent
condition after a preceding if statement
evaluates to false
. In the example above, when condition-1
evaluates to false, then statements-1 are skipped and condition-2
is checked. When condition-2 evaluates true, then statements-2
are executed. When condition-2 evaluates false, then
statements-2 are skipped and statements-3 are executed.