10.9. FOR ... IN statement

FOR ... IN statement is a control structure that executes a block of statements for all elements of an associative array.

Syntax:

FOR <element> IN <associative_array>
	<statements>...
NEXT

Before processing the block of statements, <element> variable takes value of the next element of <associative_array>.

Another syntax of FOR ... IN statement allows to execute a block of statements for hash codes identifying all elements of an associative array:

FOR <key> IN <associative_array> KEYS
	<statements>...
NEXT

For example

m := map()
m:qwer := 12
m:asdf := "hello"
for member in m
	? member
next
//         12
// hello

for key in m keys
	? key,m[key]
next
// 304733034         12
// 1190707477 hello