Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Seems logical to me. 1 = break the current level, 2 = break 1 level up, 3 = break 2 levels up, etc.

If you would do it the other way around, and then if you would add another for loop around the others, the breaks will break. You wouldn't expect that if you're modifying this code without looking at the current breaks or knowing about the break behavior.

If you however move the break statements inside a new for loop, at the most inner level, it would seem obvious that you have to update the break numbers.



Adding a label to each loop and breaking by label (like in Rust) feels better and more resistant to code changes




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: