Web Analytics Made Easy -
StatCounter Multiple case values in a switch? - CodingForum

Announcement

Collapse
No announcement yet.

Multiple case values in a switch?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple case values in a switch?

    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?) ?

  • #2
    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;
    }
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

    Comment


    • #3
      TnX

      Comment

      Working...
      X