data RangeInclusive
a..=b (§5.2).
Example:
fn main() io {
var sum = 0
for i in 1..=4 {
sum += i
}
print("{sum}")
}Output
10
@builtin("RangeInclusive") pub(api) data RangeInclusive<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 (included). |
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 (does not overflow at the maximum value). |
Defined in: std/core/types.oxl:360