Author Topic: What is the point of continue; ?  (Read 489 times)

I see this:
Code: [Select]
continue; often, especially in functions dealing with other files.  I do not understand why you need to tell the script to continue, since it will always do so unless you tell it specifically to stop.

Can someone explain this to me?

example from the advanced wrench GUI
Code: [Select]

if(getsubstr(%line,0,1) $= "#")
{
continue;
}
« Last Edit: February 18, 2011, 11:14:48 PM by Nexus »

It tells the game to immediately continue to the next iteration in while and for loops.

It tells the game to immediately continue to the next iteration in while and for loops.

Would it not do that if there was no continue; there?

Would it not do that if there was no continue; there?
You can have code after the continue that will be ignored if whatever triggers that continue is true, if you need to do that. I've used it in a bunch of places but can't think of a good example right now though.

Code: [Select]
for(%i=0;%i<10;%i+=1)
{
   if(%i == 5)
      continue;
  
   echo(%i);
}
Quote
1
2
3
4
6
7
8
9

i'm not the one who asked it, but i was wondering this also.
thanks for the clarification Space.

All right, that makes a bit more sense.  Locking.