simple way of continuing out of outter loop

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Slaughter

    simple way of continuing out of outter loop

    Say I have two nested foreach loops, is there any simple way of continuing
    out of the outter most loop depending on what happens in the inner most?

    e.g.,

    foreach(int i in I)
    {
    foreach(int j in J)
    if (j == 3)
    break.continue;
    }

    where break.continue means break out of inner loop and continue in outter
    loop.

    I doubt such a thing exists but just curious

    Thanks,
    Jon



  • Ben Voigt [C++ MVP]

    #2
    Re: simple way of continuing out of outter loop

    Jon Slaughter wrote:
    Say I have two nested foreach loops, is there any simple way of
    continuing out of the outter most loop depending on what happens in
    the inner most?
    e.g.,
    >
    foreach(int i in I)
    {
    foreach(int j in J)
    if (j == 3)
    break.continue;
    }
    >
    where break.continue means break out of inner loop and continue in
    outter loop.
    With the code you showed, just "break;" will do exactly that (because the
    inner loop is the last statement block in the outer loop body).
    >
    I doubt such a thing exists but just curious
    >
    Thanks,
    Jon

    Comment

    Working...