@head @module std @title Class std::Range @index Range @implements Iterable @supertypes

Instances of the Range class represent ascending sequences of integer values. A range is defined by two objects, the start (lower bound) and the stop (upper bound). The range includes integers from start up to, but not including, the stop. @class Range @desc The Range type. Range objects can be constructed using the to operator. @end

Member constants

@var start as Int @desc The lower bound of the range (included in the range). @end @var stop as Int @desc The upper bound of the range (not included in the range). @end

Methods

@fun iterator() as Iterator @desc Return an iterator object that returns all integer values between the lower bound and the upper bound, in ascending order and not including the upper bound. @end

Operations

@op x to y @optype{Int to Int -> Range} @desc Construct a range object representing a range x, x + 1, ..., y - 1. Both x and y must be integers. @end @op for x in range @optype{for Int in Range} @desc A range can be enumerated in ascending order with a for loop, starting with the lower bound and ending with one less than the upper bound. @end @op range == x @optype{Range == Object -> Boolean} @desc Range objects can be compared for equality. Two range objects are equal if and only if both their lower and upper bounds are equal. @end @op x in range @optype{Int in Range -> Boolean} @desc Return a boolean indicating whether x >= start and x < stop. @end @op Str(range) @desc Return a string representation a range. @end @op Hash(range) @desc Return the hash value of a range. @end