Open
Description
The switch case explanation is a bit misleading . There should be a break statement after every case for it to function as an if-else statement, otherwise it will evaluate all the cases.
switch (x) { // x must be int
case X1: a; break; // If x == X1 (must be a const), jump here
case X2: b; break; // Else if x == X2, jump here
default: c; // Else jump here (optional)
}
Metadata
Metadata
Assignees
Labels
No labels