2015-01-18 15:36:36 -08:00
|
|
|
^title Range Class
|
|
|
|
|
|
2015-09-22 21:19:38 -07:00
|
|
|
A range defines a bounded range of values from a starting point to a possibly
|
2016-05-21 00:24:41 -02:30
|
|
|
exclusive endpoint. [Here](../../values.html#ranges) is a friendly introduction.
|
2015-01-18 15:36:36 -08:00
|
|
|
|
|
|
|
|
Extends [Sequence](sequence.html).
|
|
|
|
|
|
2015-03-27 07:43:36 -07:00
|
|
|
## Methods
|
|
|
|
|
|
2015-01-18 15:36:36 -08:00
|
|
|
### **from**
|
|
|
|
|
|
2015-09-22 21:19:38 -07:00
|
|
|
The starting point of the range. A range may be backwards, so this can be
|
|
|
|
|
greater than [to].
|
|
|
|
|
|
|
|
|
|
:::wren
|
2015-10-18 15:56:52 -07:00
|
|
|
System.print((3..5).min) //> 3
|
|
|
|
|
System.print((4..2).min) //> 4
|
2015-01-18 15:36:36 -08:00
|
|
|
|
|
|
|
|
### **to**
|
|
|
|
|
|
2015-09-22 21:19:38 -07:00
|
|
|
The endpoint of the range. If the range is inclusive, this value is included,
|
|
|
|
|
otherwise it is not.
|
|
|
|
|
|
|
|
|
|
:::wren
|
2015-10-18 15:56:52 -07:00
|
|
|
System.print((3..5).min) //> 5
|
|
|
|
|
System.print((4..2).min) //> 2
|
2015-01-18 15:36:36 -08:00
|
|
|
|
|
|
|
|
### **min**
|
|
|
|
|
|
2015-09-22 21:19:38 -07:00
|
|
|
The minimum bound of the range. Returns either `from`, or `to`, whichever is
|
|
|
|
|
lower.
|
|
|
|
|
|
|
|
|
|
:::wren
|
2015-10-18 15:56:52 -07:00
|
|
|
System.print((3..5).min) //> 3
|
|
|
|
|
System.print((4..2).min) //> 2
|
2015-01-18 15:36:36 -08:00
|
|
|
|
|
|
|
|
### **max**
|
|
|
|
|
|
2015-09-22 21:19:38 -07:00
|
|
|
The maximum bound of the range. Returns either `from`, or `to`, whichever is
|
|
|
|
|
greater.
|
|
|
|
|
|
|
|
|
|
:::wren
|
2015-10-18 15:56:52 -07:00
|
|
|
System.print((3..5).min) //> 5
|
|
|
|
|
System.print((4..2).min) //> 4
|
2015-01-18 15:36:36 -08:00
|
|
|
|
|
|
|
|
### **isInclusive**
|
|
|
|
|
|
2015-09-22 21:19:38 -07:00
|
|
|
Whether or not the range includes `to`. (`from` is always included.)
|
|
|
|
|
|
|
|
|
|
:::wren
|
2015-10-18 15:56:52 -07:00
|
|
|
System.print((3..5).isInclusive) //> true
|
|
|
|
|
System.print((3...5).isInclusive) //> false
|
2015-01-18 15:36:36 -08:00
|
|
|
|
|
|
|
|
### **iterate**(iterator), **iteratorValue**(iterator)
|
|
|
|
|
|
2015-09-22 21:19:38 -07:00
|
|
|
Iterates over the range. Starts at `from` and increments by one towards `to`
|
|
|
|
|
until the endpoint is reached.
|