OxL Reference

data RangeInclusive

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
10
@builtin("RangeInclusive") pub(api) data RangeInclusive<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 (included).
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 (does not overflow at the maximum value).

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

See also