A range defines a bounded range of values from a starting point to a possibly exclusive endpoint. Here is a friendly introduction.
Extends Sequence.
The starting point of the range. A range may be backwards, so this can be greater than [to].
System.print((3..5).from) //> 3 System.print((4..2).from) //> 4
The endpoint of the range. If the range is inclusive, this value is included, otherwise it is not.
System.print((3..5).to) //> 5 System.print((4..2).to) //> 2
The minimum bound of the range. Returns either from
, or to
, whichever is
lower.
System.print((3..5).min) //> 3 System.print((4..2).min) //> 2
The maximum bound of the range. Returns either from
, or to
, whichever is
greater.
System.print((3..5).max) //> 5 System.print((4..2).max) //> 4
Whether or not the range includes to
. (from
is always included.)
System.print((3..5).isInclusive) //> true System.print((3...5).isInclusive) //> false
Iterates over the range. Starts at from
and increments by one towards to
until the endpoint is reached.