for: visiting each item
for color in ["red", "green", "blue"]:
say color
for character in "Pliro 🐢":
say character
for accepts a List or Text. Text iteration yields one Unicode code point
as Text per iteration. Maps are not directly iterable.
The loop variable exists only in the loop body. Every iteration receives a
fresh child scope.
The iterable expression is evaluated once. A list’s top-level element sequence
is snapshotted before iteration, so replacing a list cell during the loop does
not replace a later scalar value already selected for iteration. Nested list or
map elements retain normal shared collection storage.
Example
# language: en
for item in [10, 20, 30]:
say item
for character in "🐢ab":
say character
