Continue Considered Harmful?

I think there should be more use of continue!

Too often I come across code like:

for (...)
{
   if (!cond1)
   {
      if (!cond2)
      {
          ... highly indented lines ...
      }
   }
}

instead of

for (...)
{
   if (cond1 || cond2)
   {
      continue;
   }

   ...
}

Use it to make the code more readable!


You can write good code with or without continue and you can write bad code with or without continue.

There probably is some overlap with arguments about goto, but as far as I'm concerned the use of continue is equivalent to using break statements (in loops) or return statement from anywhere in a method body - if used correctly it can simplify the code (less likely to contain bugs, easier to maintain).


Is continue any more harmful than, say, break?

If anything, in the majority of cases where I encounter/use it, I find it makes code clearer and less spaghetti-like.