data Range
a..b (§5.2).
Example:
fn main() io {
var sum = 0
for i in 1..4 {
sum += i
}
print("{sum}")
}Вывод
6
@builtin("Range") pub(api) data Range<T>Сложность. O(1) to create; iteration is lazy.
С версии. 1.0.0-beta
Методы
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 |
Определено в: std/core/types.oxl:342