Class in prelude auto-imported

Range

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

A lazy half-open range start..end: every value from start up to, but not including, end.

Written with the .. operator; the bounds must have the same type with an Ord instance. for x in a..b and .to_vec() step by 1 (or 1.0) and work for int, byte and float bounds only. A range whose end is not greater than its start is empty.

Methods#

NameDescription
to_vecCollects the range into a new Vec<T>.

Examples#

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

See also#

  • Ord
  • int
  • byte
  • float
  • Vec: A growable, heap-allocated vector of T values.
  • RangeInclusive: A lazy inclusive range start..=end: every value from start up to and including end.
↑ ↓ navigate ↵ open