Gentee Programming Language > Documentation > Syntax | Download documentation |
The foreach loop deals with objects that contain an element list and have the following methods: first(), next(), eof(). The element type and the variable name are specified after foreach. Then the comma delimited expression is specified that returns the object list; and the loop body follows.
<foreach> ::= foreach [<type name>] <variable name> [<array>]','<expression><block>
An index variable will be created before each foreach statement. The expression is evaluated once before the loop iteration starts. The loop passes through each object element sequentially. So, the index variable will contain the next element.
foreach str k, mystrlist
{
print( k )
}
See also
return, break, continue Instructions
Copyright © 2004-2006 Gentee Inc. All rights reserved. |