up previous next
break out of a loop command
This command may be used only inside a loop statement (
for
,
foreach
,
repeat
, or
while
).
When executed, the entire current loop statement is terminated, and
control passes to the command following the loop statement. If you
just want to skip to the next iteration of the current loop statement
use instead
continue
.
In the case of nested loops
break
leaves just the innermost loop
statement in which the
break
statement appears.
/**/ for i := 5 to 1 step -1 do
/**/ for j := 1 to 10 do
/**/ print j, " ";
/**/ if j = i then println; break; endif;
/**/ endfor;
/**/ endfor;
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
|