Switch statement inside a switch statement?

前端 未结 8 1792
傲寒
傲寒 2021-02-07 02:40

I have to evaluate many conditions. In my case, I have to do something like this:

switch(id)
{
    case 5:
         // switch some other cases here
    case 6:
          


        
8条回答
  •  失恋的感觉
    2021-02-07 03:24

    I would call a function and pass in the aditional cases and in the function do a switch case on them. Makes cleaner code. Another method I often use is indeed nested if's

提交回复
热议问题