is it correct to use continue too skip some loop conditions?

or there other way
yes. The other way is to reverse the continue condition and use the if-body for the code to be executed. Can get messy.
Last edited on
With example:
1
2
3
4
5
6
for/while/do ...
{
   A;
   if ( condB ) continue;
   B;
}


1
2
3
4
5
6
7
for/while/do ...
{
   A;
   if ( not condB ) {
      B;
   }
}

In both cases the statement B is evaluated only when the condition condB is false.
Last edited on
Topic archived. No new replies allowed.