I have really simple code where I use break
inside inner loop:
for (int it=0; it<5; it++) {
for (int it2=0; it2<5; it2++) {
if (it2==2)
break; //break here not it2, but it loop
NSLog(@"it=%d it2=%d", it, it2);
}
}
I receive an output:
it=0 it2=0, it=0 it2=1,
it=1 it2=0, it=1 it2=1,
it=2 it2=0, it=2 it2=1,
it=3 it2=0, it=3 it2=1,
it=4 it2=0, it=4 it2=1
I know in some programic languages there is possibility to determine on which loop break statement should affect. Is it possible to call break
to stop outer loop (for
with it
variable)?