Test for multiple cases in a switch, like an OR (||)

后端 未结 6 643
暗喜
暗喜 2020-11-28 01:16

How would you use a switch case when you need to test for a or b in the same case?

switch (pagei         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 01:56

    You need to make two case labels.

    Control will fall through from the first label to the second, so they'll both execute the same code.

提交回复
热议问题