Home News DOC Class DL Others Cooker
Documents  >  Tutorial  >  Continue
Continue statement

It forcebly continue the loop statement.


Table of contents:


Format

continue

Semicolon

Beginning of loop

Example

Format

The format of the continue statement is:


continue ;


It ends the current loop of the loop statement and executes the next loop.

Statements after the continue statement are ignored, and execution control jumps to the beginning of a nearest loop surrounding the continue statement.

continue

A keyword that indicates that it is a continue statement.

Semicolon

The end of a continue statement is represented by a semicolon.

Beginning of loop

A continue statement returns execution control to the beginning of a loop statement, but its position depends on the type of loop statement.

while statement

while ( Conditional-expression )

...

continue;

...

endwhile


The conditional expression evaluates whether the loop can be executed.

The conditional expression is evaluated every loop. Therefore, the loop resumes from the evaluation of the conditional expression.

each statement

each ( Collection-expression )

...

continue;

...

endeach


The collection expression determines a target collection.

The target is evaluated only once at the beginning. Therefore, the loop resumes from the next statement of the collection expression.

fromto statement

fromto ( Start-index, End-index )

...

continue;

...

endfromto


The start and end indexes determine the start and end values of the loop index.

The start and end indexes are evaluated only once at the beginning, but the current loop index is evaluated every loop. Therefore, the loop resumes from the evaluation of the current loop index.

keepon statement

keepon ( Number-expression )

...

continue;

...

endkeepon


The number expression determines the total number of loop.

The total number is evaluated only once at the beginning, but the cumulative number of loop is evaluated every loop. Therefore, the loop resumes from the evaluation of the cumulative number.

Example

1:

class example

2:

open method void someMethod()

3:

keepon(10)

4:

if(__index < 5)

5:

continue;

6:

endif

7:

endkeepon

8:

em

9:

ec

When the someMethod() method is called, it rushes into a keepon loop.

At the beginning of the loop, the cumulative number is stored in the reserved variable "__index".


If "__index" is 5 times or less, execution control returns with the continue statement.

From the sixth time onward, execution control returns in due to the "endkeepon".

Next
Previous
Copyright © Rice All rights reserved.