1

Trying to figure out how to jump to the next iteration for a for loop from within a nested switch statement. Everything I can see will only break me out of the current switch.

for(var loop = 0; loop <= 10; loop++) {
  switch(control1) {
    case 1:
      break;
    case 2:
      switch(a) {
        case "a":
          if(evaluatestotrue) {
            Jump to next loop iteration;
            NOT SURE WHAT TO PUT HERE (break? contiune?);
           }
           break;
         default:
           patternfound = true;
           break; 
      }
      ... additional code ...
      break;
  }
}

Everything seems to drop me out of the the inner switch, but what i need is to jump all the way to the next iteration of loop.

Keith Clark
  • 609
  • 1
  • 7
  • 19
  • 2
    you are probably looking for the `continue;` keyword. – Felix Castor Feb 02 '22 at 20:47
  • @FelixCastor OP *knows* that they can use "continue" based on comment in the sample code - I'm not exactly sure what type of help/opinions they are looking for here... But since we already have very similar question about nested `foreach` duplicate closure seem to be a good choice (instead of probably more appropriate "need more details" or "opinion-based"). Keith can [edit] the question if duplicate is not what they are asking about (again question already suggests to use `continue` to get out). – Alexei Levenkov Feb 02 '22 at 20:54
  • Ok, that's what I get for reading to much into the "logic" of an IDE. Even though it showed it as unreachable/redundant code, continue did exactly what it was supposed to when I ran trial data thru it. Sorry for taking up everyone's time. – Keith Clark Feb 02 '22 at 21:08

0 Answers0