continue
Details
continue is used to end the current iteration early, skip the statements after continue in the loop body, and directly proceed to the next condition check ( for , while ) or the next execution of the loop body ( do-while ).
Examples
def printloop(a,b){
for(s in a:b){
if(mod(s,10)==1)
continue
print s
}
}
printloop(10,13);
/* output
10
12
*/
Use continue in a while loop to skip specific values.
x = 0
while (x < 10) {
x += 1
if (x % 3 == 0) continue
print x
}
// output:
// 1
// 2
// 4
// 5
// 7
// 8
// 10
Note: When using continue in a while loop, make sure that the loop variable update statement is placed before continue. Otherwise, when continue skips subsequent statements, the loop variable will not be updated, causing an infinite loop. This is a key difference between while + continue and for + continue: the iteration expression of a for loop is automatically executed at the end of each iteration and is not affected by continue.
