Ranges
Exclusive and inclusive integer ranges used in for loops, match patterns, and membership tests.
Summary
0..10 is exclusive (0 through 9); 0..=10 is inclusive (0 through 10). Ranges are a first-class type; type(r) returns "range" and len(r) gives the count. The in operator tests membership. Range patterns work in match arms.
Canonical
0..10 -- exclusive range (0 through 9)
1..=5 -- inclusive range (1 through 5)
let r = 0..5
println(type(r)) -- range
println(len(r)) -- 5
-- iteration
for i in 0..5 { print("{i} ") } -- 0 1 2 3 4
for i in 1..=3 { print("{i} ") } -- 1 2 3
-- membership test
println(3 in 1..5) -- true0..10 does not include 10. Use 0..=10 for inclusive.