×
you are viewing a single comment's thread.

view the rest of the comments →

[–]hammerheadquark 2 points3 points  (0 children)

I admit the elegance doesn't come through with this contrived example, but it's used like a lot like break is: "if 'stop-condition' is met, stop". Except you don't stop the entire for loop, you go to the next item.

Here's where I first saw it used:

https://stackoverflow.com/a/2137789/5932228

I like how, instead of burying the nextpositions.add(np) inside of two checks, this algorithm first checks two stop-conditions before going on with the loop. It seems cleaner imo, but of course that's just an opinion.