for (range)
Iterates over a range or collection.
Syntax
for i in 1..=n { }Description
1..n (exclusive of n), 1..=n (inclusive of n). For collections: for x in &v { }.
Example
Loading editor…
Expected output
1 2 3
When to use?
Specific repetition, traversing collections.