Switch statement inside a switch statement?

前端 未结 8 1808
傲寒
傲寒 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:16

    Avoid !

    Try to refactor your code to eliminate switch cases. Switch statements for behaviours can be refactored into Strategy Pattern.

    Strategy Pattern](![Strategy Pattern

提交回复
热议问题