Here’s another programming innovation that could perhaps* have been designed bit better.
Check out the code:
switch(value) {
case 1:
case 2:
// do something
break; // why here is a break?
}
It’s a “newbie mistake” to forget “break” from switch statements, but what if the syntax would be something like this:
switch(value) {
case 1, 2:
{
// do something
}
}
Marks {} are already used to indicate a “section” in programming languages (just think about IF), so why not use them in “switch” cases as well? Or why not replace “break;” with something like “continue;” – so that people would need to type extra stuff if they do not want to break the case.
Just wondering.
* and by “perhaps” I mean, that in reality I don’t have a clue how this should be done. I just think this for the beginner’s the command “break;” can be bit problematic sometimes.









