Conditional structures: Difference between revisions
Content added Content deleted
Line 73: | Line 73: | ||
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: |
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: |
||
<lang ada>case Today |
<lang ada>case Today is |
||
when Monday => |
when Monday => |
||
Compute_Starting_Balance; |
Compute_Starting_Balance; |
||
Line 85: | Line 85: | ||
The syntactically correct version: |
The syntactically correct version: |
||
<lang ada>case Today |
<lang ada>case Today is |
||
when Saturday | Sunday => |
when Saturday | Sunday => |
||
null; -- don't do anything, if Today is Saturday or Sunday |
null; -- don't do anything, if Today is Saturday or Sunday |