I really can't help noticing that a language that writes end if
also writes elsif
and not else if
,
Its a trivial point and here is the trivial answer!
if a=1 then b:=1
elsif a=2 then b:=2
else b:=-1;
end if
but here is the ambiguity that would result:
if a=1 then b:=1
else if a=2 then b:=2
else b:=-1;
end if
There are now two if
but just one end if
.
The correct equivelant code avoiding elsif
would be;
if a=1 then b:=1
else
if a=2 then b:=2
else b:=-1;
end if
end if
Well what about elseif
? One space could mess that up. So then it's elsif
or elif
and who cares which.