| 1 | = Continue Statement = |
| 2 | The '''continue''' statement forces transfer of control to the controlling expression of the nearest (smallest) enclosing loop. |
| 3 | |
| 4 | Any remaining statements in the current iteration are not executed. The next iteration of the loop is determined as follows: |
| 5 | |
| 6 | * In a while loop, the next iteration starts by reevaluating the controlling expression of the while statement. |
| 7 | * In a for loop, continue causes the loop counter to increment or enumerator step to be executed[[BR]] |
| 8 | then the loop termination cond-expr is reevaluated and, depending on the result, the loop either terminates or another iteration occurs. |
| 9 | |
| 10 | == Grammar == |
| 11 | {{{ |
| 12 | continue |
| 13 | }}} |
| 14 | == Example == |
| 15 | |
| 16 | The following example shows how the continue statement can be used to bypass sections of code and begin the next iteration of a loop. |
| 17 | {{{ |
| 18 | def main is shared |
| 19 | i = 0 |
| 20 | post while i < 3 # do |
| 21 | i += 1 |
| 22 | print 'before the continue' |
| 23 | continue |
| 24 | print 'after the continue, should never print' |
| 25 | |
| 26 | print 'after the do loop' |
| 27 | |
| 28 | # Outputs: |
| 29 | |
| 30 | before the continue |
| 31 | before the continue |
| 32 | before the continue |
| 33 | after the do loop |
| 34 | }}} |