You can write a check on the condition that a variable belongs to a range of values, for example:

if (0 < i && i < 10) { // ... } 

Is it possible to do a similar check for switch / case statements without listing case's inside the switch?

 switch (i) { case 1: // ... break; // ... case 9: // ... break; } 
  • one
    this can be done in Pascal / Delphi :) - KoVadim

1 answer 1

No you can not. It is possible so for small intervals of values:

 switch (i) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: // ... break; } 

Note that there is no break between successive choices of case .