I recently managed to write a piece of code similar to this:
switch (x) {
case a: case b: case c:
break;
case d: case e: case f:
break;
}
Then I made a mistake and wrote a similar code with a syntax error: I forgot to write the case keyword:
switch (x) {
case a: b: c:
break;
case d: e: f:
break;
}
This syntax is valid in some other languages, and the switch goes through all the values.
In fact, this is also relevant, since I did not receive a syntax error: but the incorrect behavior of the program that ran the switch smoothly only passed values without the case keyword.
Why? What is b; c :, e: and f: average in the second snip?
Are they shortcuts ? And then, how can they be on the same line? What am I missing, what I don’t understand behind this strange mistake?
Edit: they really are shortcuts . , , @Bathsheba, , . , Java ( ) , . .
.