for loops

There are 5 types of for loops in langur.

3 part for init; test; increment { ... }
1 part for test { ... }
unlimited for { ... }
for in for .x in .y { ... }
for of for .x of .y { ... }
3 part
for init; test;
increment { ... }
1 part
for test { ... }
unlimited
for { ... }
for in
for .x in .y { ... }
for of
for .x of .y { ... }

A for in loop iterates over the values of an array or string, or over a range. A for of loop iterates over the index itself.

Loop variables of for in and for of loops are protected.

No parentheses are used.

Curly braces are required on the for loop body.

You can omit any section from a 3 part loop, but not the 2 semicolons.

The init and increment sections are each a comma-delimited list (may contain multiple expressions).

Langur uses 1-based indexing.

Currently, loops are expressions returning null. This is likely going to change.

break / next

Use break to break out of a loop, and next to try the next iteration.

These keywords apply only to loops (never to given).