Conditional structures: Difference between revisions

Content added Content deleted
m (→‎case expressions: Highlight variables in text as italic)
m (→‎case without a default: the error discussed isn’t syntactic)
 
Line 615: Line 615:
===case without a default===
===case without a default===
When there is no '''when others''' clause, the compiler will complain about any uncovered alternative. This defends against a common reason for bugs in other languages.
When there is no '''when others''' clause, the compiler will complain about any uncovered alternative. This defends against a common reason for bugs in other languages.
I.e., the following code is syntactically incorrect:
I.e., the following code is incorrect:


<syntaxhighlight lang="ada">case Today is
<syntaxhighlight lang="ada">case Today is
Line 627: Line 627:
end case;</syntaxhighlight>
end case;</syntaxhighlight>


The syntactically correct version:
The correct version:


<syntaxhighlight lang="ada">case Today is
<syntaxhighlight lang="ada">case Today is