The case of the switch is a way to wrap a block of instructions and execute it (part), starting here and ending here. A case match denotes a beginning, and the next break denotes an end.
A block may contain several instructions:
{ instruction_A; instruction_B; instruction_C; instruction_D; }
case say where to dynamically run based on the value of switch :
switch(value) { case one: instruction_A; instruction_B; case two: instruction_C; case three: instruction_D; }
In the case of one all commands will be called, since there is no gap. Case two will execute C and D if there are no exceptions (c ;.
The break statements tell where to stop, and mean that you can skip several cases:
switch(value) { case one: instruction_A; instruction_B; case two: instruction_C; break; case three: instruction_D; }
Case one now execute A, B, and C, but not D.
source share