Multple Criteria in a Single Case inside a Switch Statement

This question already has an answer here:

  • Switch statement multiple cases in JavaScript 15 answers

  • There is one hacky switch style that allows you to specify ranges:

    switch (true) {
        case blah >= 0 && blah <= 3:
            //do this
            break
        default:
            //do that
    }
    

    It sometimes useful in cases like this.

    Maybe it'll do what you want.


    This might be what you are looking for. If it is please more clearly define your problem/question.

    switch (x) {
       case 0:
       case 1:
       case 2:
       case 3:
       // do this
       break;
       default:
       // do this
    }
    

    See also Multiple Cases in Switch:

    链接地址: http://www.djcxy.com/p/84460.html

    上一篇: 有人可以帮助我解决这个逻辑使用C#

    下一篇: Switch语句中单个案例中的多重标准