Files
wren/doc/site/modules/core/range.markdown
T
kylewcharters@gmail.com aef30ca4a1 fix: correct method examples in Range docs to use from/to/max instead of min
The documentation examples for the `from`, `to`, and `max` properties of the Range class were incorrectly calling `.min` instead of the actual method names. Updated the code samples in the `from`, `to`, and `max` sections to use the correct method calls, ensuring the examples match the documented property names and produce the expected output values.
2017-10-23 17:48:43 +00:00

1.3 KiB

^title Range Class

A range defines a bounded range of values from a starting point to a possibly exclusive endpoint. Here is a friendly introduction.

Extends Sequence.

Methods

from

The starting point of the range. A range may be backwards, so this can be greater than [to].

:::wren
System.print((3..5).from) //> 3
System.print((4..2).from) //> 4

to

The endpoint of the range. If the range is inclusive, this value is included, otherwise it is not.

:::wren
System.print((3..5).to) //> 5
System.print((4..2).to) //> 2

min

The minimum bound of the range. Returns either from, or to, whichever is lower.

:::wren
System.print((3..5).min) //> 3
System.print((4..2).min) //> 2

max

The maximum bound of the range. Returns either from, or to, whichever is greater.

:::wren
System.print((3..5).max) //> 5
System.print((4..2).max) //> 4

isInclusive

Whether or not the range includes to. (from is always included.)

:::wren
System.print((3..5).isInclusive)   //> true
System.print((3...5).isInclusive)  //> false

iterate(iterator), iteratorValue(iterator)

Iterates over the range. Starts at from and increments by one towards to until the endpoint is reached.