data Range
a..b (§5.2).
Example:
fn main() io {
var sum = 0
for i in 1..4 {
sum += i
}
print("{sum}")
}Output
6
@builtin("Range") pub(api) data Range<T>Complexity. O(1) to create; iteration is lazy.
Since. 1.0.0-beta
Methods
lo | () -> TThe lower bound of the range. |
hi | () -> TThe upper bound of the range (excluded). |
contains | (x: &T) -> bool where T: Ordlo <= x && x < hi for any ordered T (D-3563); the same as x in lo..hi. |
iter | () -> iter<T> where T: OrdLazy iterator over lo..hi (integer and char ranges only |
Defined in: std/core/types.oxl:342