-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
6u29
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
There is a disavantage of SWITCH statement (in comparsion with C): it can't receive range of values or conditions as case parameters.
JUSTIFICATION :
It is necessary because it will significiantly reduce the code writing for switch statement and make it much more flexible and east-to-use
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should work at any expr variable randomed value.
ACTUAL -
But now switch statement doesn't work if cases about range (3;7] and [1;3] exist. I think it will be very useful to add support of contions and ranges of values to Java like it is in C.
---------- BEGIN SOURCE ----------
int expr=(int) (Math.random()*10);
switch (expr) {
case 1...3:
//There goes some code
break;
case 0:
//There goes some code
break;
case >3,<=7:
//There goes some code
break;
default:
//There goes some code
}
---------- END SOURCE ----------
There is a disavantage of SWITCH statement (in comparsion with C): it can't receive range of values or conditions as case parameters.
JUSTIFICATION :
It is necessary because it will significiantly reduce the code writing for switch statement and make it much more flexible and east-to-use
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should work at any expr variable randomed value.
ACTUAL -
But now switch statement doesn't work if cases about range (3;7] and [1;3] exist. I think it will be very useful to add support of contions and ranges of values to Java like it is in C.
---------- BEGIN SOURCE ----------
int expr=(int) (Math.random()*10);
switch (expr) {
case 1...3:
//There goes some code
break;
case 0:
//There goes some code
break;
case >3,<=7:
//There goes some code
break;
default:
//There goes some code
}
---------- END SOURCE ----------
- duplicates
-
JDK-8061403 Allow multiple constants and ranges in case labels
-
- Closed
-
- relates to
-
JDK-6827009 Project Coin: Strings in Switch
-
- Closed
-