Have you ever been inside a nested loop and wanted to BREAK or CONTINUE the outer loop...not the inner one you're presently iterating?
for-each x data [ // outer loop
for-each y data [ // inner loop
if some-test [
break // !!! want this to break outer loop, d'oh
]
...
]
...
]
Well you're in luck ...thanks to the "simple magic" loop result protocol, you have an answer.
for-each x data [
for-each y data [
if some-test [
break
]
...
] else [break]
...
]
If you read the details, ELSE will run if-and-only-if the loop breaks. So you can feel confident putting the second BREAK in there.
What if you had wanted to CONTINUE the outer loop instead? Well, all you need to do there is break the inner loop and use that signal to continue the outer loop.
for-each x data [
for-each y data [
if some-test [
break // in order to continue outer loop
]
...
] else [continue] // ta-da!
...
]
Pretty sweet, eh? And don't miss out on how you can use OR to test for either a BREAK -or- the loop body never running due to absence of data or iterations, which comes in handy quite often.