Class in prelude auto-imported

RangeInclusive

class RangeInclusive<T>
Source: compiler/src/builtin_docs/prelude.hy

A lazy inclusive range start..=end: every value from start up to and including end.

Written with the ..= operator. Iteration and .to_vec() follow the same rules as Range: step 1 (or 1.0), numeric bounds only, and empty when end is less than start.

Methods#

NameDescription
to_vecCollects the range into a new Vec<T>, including the end value.

Examples#

use tests::assert;
let sum = 0;
for i in 1..=4 {
    sum = sum + i;
}
assert!(sum == 10);

See also#

  • Range
  • Vec: A growable, heap-allocated vector of T values.
↑ ↓ navigate ↵ open