else is a reserved word which starts a fallback-branch if all other named cases do not apply.
It can occur in
else-branch obtains program flow, if no other condition has been met.
It cannot be paired with an explicit expression, but depends on expressions stated at others place, so an
else per se does not have a condition.
if … then … else-statements, instructions are executed to the following scheme:
if expression then trueStatement else falseStatement;
falseStatement is executed if
expression evaluates to
else-branch assumes program flow, if no
case expression of value0: action0; value1: action1; else action2; end;
expression neither evaluates to
action2 is executed.
In Pascal there is no
if back to back does not pose a problem.
Note, that the second
if … then constitutes on its own a single statement.
The requirement that
else is followed by a statement is therefore fulfilled.
if expression0 then begin action0; end else if expression1 then begin action1; end;
if … then … else
if itIsMorning() then if itIsAHoliday() then begin sleep; end else begin wakeUp; dress; brushTeeth; …; end else begin …; end;
The reference guide explains, quote:
If.. then .. elseconstructs, some ambiguity may [arise] as to which
elsestatement pairs with which
ifstatement. The rule is that the
elsekeyword matches the first
ifkeyword (searching backwards) not already matched by an