Is goto ok for breaking out of nested loops?

后端 未结 10 1836
忘掉有多难
忘掉有多难 2021-01-18 04:33

JavaScript supports a goto like syntax for breaking out of nested loops. It\'s not a great idea in general, but it\'s considered acceptable practice. C# does not directly

10条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-18 05:14

    IMO it is acceptable in languages that do not support break n; where n specifies the number of loops it should break out.
    At least it's much more readable than setting a variable that is then checked in the outer loop.

提交回复
热议问题