Just as in Java, you can use
break;
(without a label name) if you want to break out of the closest enclosing loop. Unlike in Java, you can also repeat the break
keyword in order to break out of some other enclosing loop. For example, if you have an outer loop and an inner loop and want to break out of both loops from inside the inner loop, then you can either label the outer loop and list the label in the break
statement:label Outer:
while ...
{
...
while ...
{
...
break Outer;
...
}
...
}
or you can use a break break;
statement, which breaks out of two levels of loops:while ...
{
...
while ...
{
...
break break;
...
}
...
}
Rustan