Walk Loops (skip & stop)
.walk() is Luma’s universal iteration mechanism. It works on lists, maps, sets, ranges, and other walkable types. For the basics of .walk() syntax, see the documentation for each data type (Lists, Maps, Sets, Ranges).
This page covers loop control flow: skipping iterations and exiting a walk early.
skip
Use skip to skip the rest of the current iteration and move to the next element. It is the Luma equivalent of continue in other languages.
nums: [int] = [1, -2, 3, -4, 5]
nums.walk(n) -> {
if n < 0 { skip }
print(n)
}
// Output: 1, 3, 5skip is a bare keyword — no arguments, no parentheses.
stop
Use stop to exit the walk entirely. It is the Luma equivalent of break in other languages.
nums: [int] = [1, 2, 3, 100, 5, 6]
nums.walk(n) -> {
if n > 50 { stop }
print(n)
}
// Output: 1, 2, 3stop is a bare keyword — no arguments, no parentheses.
Combining skip and stop
You can use both in the same walk. skip and stop are independent — each does exactly one thing.
nums: [int] = [1, -2, 3, -4, 5, 100, 6]
nums.walk(n) -> {
if n < 0 { skip }
if n > 50 { stop }
print(n)
}
// Output: 1, 3, 5Works with all walkable types
skip and stop work in any .walk() block — lists, maps, sets, and ranges all compile to the same kind of loop.
Maps
ages: {str: int} = {"Alice": 30, "Bob": 17, "Charlie": 25}
ages.walk(name, age) -> {
if age < 18 { skip }
print("${name}: ${age}")
}Sets
ids: {int} = {5, 12, 3, 99, 7}
ids.walk(id) -> {
if id > 50 { stop }
print(id)
}Ranges
(1..=20).walk(n) -> {
if n % 2 == 0 { skip }
if n > 10 { stop }
print(n)
}
// Output: 1, 3, 5, 7, 9Common patterns
Find first match
names: [str] = ["Alice", "Bob", "Charlie"]
found: str = ""
names.walk(name) -> {
if name.starts_with("C") {
found = name
stop
}
}
print(found) // CharlieProcess with exceptions
scores: [int] = [85, -1, 92, 0, 78]
scores.walk(s) -> {
if s <= 0 { skip }
print("Score: ${s}")
}
// Output: Score: 85, Score: 92, Score: 78skip, stop, and return
Three levels of control, three keywords:
| Keyword | Effect |
|---|---|
skip |
Skip to the next iteration of the walk |
stop |
Exit the walk entirely |
return |
Exit the enclosing function |
fn process(nums: [int]) -> int {
total: int = 0
nums.walk(n) -> {
if n < 0 { skip } // skip negatives
if n > 100 { stop } // stop if too large
total = total + n
}
return total
}Design notes
skipandstopare bare keywords with no arguments- They are named to match the “walking” metaphor: you skip a step, or stop walking
- No labeled loops — there is no “stop outer walk” syntax. If needed, this may be added in the future
- Using
skiporstopoutside a walk block will produce a compile error