How can I rewrite this (cleanly) without gotos?

Posted by Jared P on Stack Overflow See other posts from Stack Overflow or by Jared P
Published on 2010-04-02T21:30:31Z Indexed on 2010/04/02 21:33 UTC
Read the original article Hit count: 123

Filed under:
|

How can I do this cleanly without gotos?

loop:
  if(condition1){
    something();
  } else if (condition2) {
    somethingDifferent();
  } else {
    mostOfTheWork();
    goto loop;
  }

I'd prefer not to use breaks as well. Furthermore, it is expected to loop several (adv 40) times before doing something else, so the mostOfTheWork part would most likely be as high up as possible, even if just for readability. Thanks in advance.

© Stack Overflow or respective owner

Related posts about goto

Related posts about control-flow