|
||||||||||||
|
|
||||||||||||
SwitchThe switch statement transfers control to one fo several statements depending on the the value of a candidate expression. There are three flavors of switch:
No two of the case constant expressions may have the same value, although non-constant cases may yield to same values. If these is a matching case for value yielded by the expression then the statement assosicated with that case are evaluted. Evaluation of statements in switch "falls through cases" provided that no flow control statements are encountered.
If none of the cases could be matched and if there is a `` Default statement may only appear once, in any position inside the body of switch statement. A break statement will terminate execution of switch. Continue statement cannot be used inside switch, although special continue .. case and continue .. default are used to transfer the execution to specified case statement. switch := "switch" "(" expr-startcandidate ")" "{" ( "case" exprvalue ( "," exprvalue )* ":" statement * | "default" ":" statement * ) * "}"
See also
| Statements
| Break
| Continue .. case
| Compound statements
| <switch>, <case> and <default>
| Statement labels
| Grammar
|
||||||||||||
|
|
||||||||||||