Difference between revisions of "Using continue"

From Catglobe Wiki
Jump to: navigation, search
 
Line 1: Line 1:
 
[[Category:Program_Control_Statements]]
 
[[Category:Program_Control_Statements]]

+
{{HelpFiles}}
  
 
===Using continue===
 
===Using continue===

Latest revision as of 08:16, 14 December 2011



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