If condition occurs in the inner for
loop I want to break
the inner and next
the outer.
I could create a flag in the inner before the break
statement and then evaluate in the outer, this is a silly example:
for (i in 1:3) {
NEXT <- FALSE
for (j in 1:3) {
if (j==2 && i==2) {
NEXT <- TRUE
break
}
}
if (NEXT) next
cat("\n", i, " ... some i stuff ...")
}
Is there an elegant way to do it? Something like:
for (i in 1:3) {
for (j in 1:3) {
if (j==2 && i==2) {
break
# next (outer)
}
}
cat("\n", i, " ... some i stuff ...")
}
There a similar/duplicate question but I think it doesn't answer's mine, because in the question's outer loop it does nothing after the inner loop.