SplitScript reference / Language / for
for
keyword
for value in iterable { ... }
Iterates over an array, set, or integer range.
The iterable expression is evaluated exactly once. The read-only element binding is lexically scoped to the body and inferred from [T], [T; N], Set, or an integer range. break and continue target the nearest loop. In onAttach, a body containing await or retry preserves the iterable and current binding across suspension. Inside settings, an inclusive range expands a settings family at compile time instead of creating a runtime loop.
Examples
Iterate over an array
for label in ["one", "two"] {
print(label)
}
Declare a family of settings
/// Controls each generated level split.
for level in 2..=36 {
`Level {level}` key `{level}`: true,
}