PDA

View Full Version : Multiple case values in a switch?


Thummy
06-29-2002, 11:42 AM
I wanna do like this:

switch(SomeValue){
case A (or?) N (or?) R: {return "first_result"; break;}
case F (or?) E (or?) Z: {return "second_result"; break;}
case T (or?) I (or?) B: {return "third_result"; break;}
default: (return "default_result"; break}
}
What separartor do I need instead of the (or?) ?

joh6nn
06-29-2002, 11:47 AM
none. it's called fall through. if it's case 'A', then it will 'fall through' to case 'N'. Case 'N' falls through to 'R', which finally does something.

switch(SomeValue){

case 'A':
case 'N':
case 'R':
return "first_result"; break;

case 'F':
case 'E':
case 'Z':
return "second_result"; break;

case 'T':
case 'I':
case 'B':
return "third_result"; break;

default:
return "default_result"; break;
}

Thummy
06-29-2002, 11:55 AM
TnX :thumbsup: