OxL Reference

data Range

a..b (§5.2).

Example:

oxl✓ checked in CI
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() -> T
The lower bound of the range.
hi() -> T
The upper bound of the range (excluded).
contains(x: &T) -> bool where T: Ord
lo <= x && x < hi for any ordered T (D-3563); the same as x in lo..hi.
iter() -> iter<T> where T: Ord
Lazy iterator over lo..hi (integer and char ranges only

Defined in: std/core/types.oxl:342

See also