Unreachable Statement with Break

前端 未结 4 1459
北海茫月
北海茫月 2020-12-11 23:09

So I had a previous question but realized I posted the wrong offending code. I\'ve marked the offending statements below.

What I am trying to do is set the preceden

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 23:47

    If you put a return, then the function returns before the break is executed and therefore the break will never be reached.

    Instead you could use a variable that you set to a desired value and after the switch return that. Or just get rid of the break statements.

提交回复
热议问题