| case |
|
grammar |
| |
A flow control statement whose valid context is only within a
switch
statement.
Control passes to the statements following this statement whenever the
unary expression associated with it has a value equal to the
switch
statement argument.
The unary expression is evaluated once when the
switch
statement is first encountered.
When a
case
statement is selected,
the first
break
statement encountered in the same context
marks the end of statements to be executed.
Its usage description can be summarized as follows:
Statement:
case UnaryExpression :
If the unary expressions of two or more
case
statements within the same
switch
statement evaluate to the same value, a warning is issued and only the
first matching
case
statement is selected.
| |
| Example: |
This example involving a
case
statement:
import yoix.util.Calendar.*;
Calendar c;
stdout.nextbuf = "Today is ";
switch(c.dayofweek) {
case SUNDAY:
stdout.nextline = "Sunday";
break;
case MONDAY:
stdout.nextline = "Monday";
break;
case TUESDAY:
stdout.nextline = "Tuesday";
break;
case WEDNESDAY:
stdout.nextline = "Wednesday";
break;
case THURSDAY:
stdout.nextline = "Thursday";
break;
case FRIDAY:
stdout.nextline = "Friday";
break;
case SATURDAY:
stdout.nextline = "Saturday";
break;
default:
stdout.nextline = "in trouble!";
break;
}
yields this sort of output:
Today is Thursday
| | |
| See Also: |
break,
default,
reference,
switch
|
|
Yoix is a registered trademark of AT&T Inc.
|