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