For loops

for pattern in iterable consumes an array, range, dictionary, or iterator. The loop head must match every item, so it uses an irrefutable pattern.

Bindings are immutable, scoped to the body, and fresh each iteration. A tuple head destructures tuple elements, including values produced by enumerate().

fn main() {
  for (index, letter) in ["a", "b"].enumerate() {
    println("$index:$letter")
  }
}
Output & diagnostics
Expected:
0:a
1:b
Ctrl/⌘+Enter runs the current lesson.