What is a neat way of breaking out of many for loops at once?

后端 未结 14 1497
既然无缘
既然无缘 2020-12-28 19:33

Suppose I need to break out of three or four nested for loops at once at the occurence of some event inside the innermost loop. What is a neat way of doing that?

14条回答
  •  一向
    一向 (楼主)
    2020-12-28 19:51

    Put all the loops in a function and just return instead of break.

提交回复
热议问题