this question has answer here:
is there simple way break out of inner loop, i.e. fro loop within loop? without having set additional flags example
there 3 basic methods:
using additional boolean flag
using labelled loop (
label: ...
) ,break label
extracting loops separate function/method , using
return
instead ofbreak
.
from code quality perspective believe 3. best solution.
Comments
Post a Comment