Using continue

From Catglobe Wiki
Jump to: navigation, search



Using continue

It is possible to force an early iteration of a loop, bypassing the loop’s normal control structure. This is accomplished using continue. The continue statement forces the next iteration of the loop to take place, skipping any code in between. Thus, continue is essentially the complement of break.

For example, the following script uses continue to help print the even numbers between 0 and 10:

{

for(number i = 1; i<10; i=i+1)

{

if (i%2 == 1) continue;

print(i);

}

}

The output from the script is shown here:

2

4

6

8