Dealing with combining cases & duplicate cases in switch statements

前端 未结 4 647
猫巷女王i
猫巷女王i 2021-01-15 14:28

Is it okay to combine cases that share assignments and repeat the case for assignments that are not shared, or is it preferred to just keep each se

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-15 14:55

    I would say don't combine - too high of a chance of making a mistake...like you did. The 2nd case 180 will never be reached, since the first one has a break; after it.

    If everything is the same, I think it's ok to combine though (like the -90, 90).

提交回复
热议问题