Range
struct Amethyst::Runtime::Range implements Enumerable[Int]endAn integer range. A range literal 1..10 includes
its end, and 1...10 leaves it out. Range is a value type, and iterating over it
yields each integer from start up to last.
(1..3).each { |i| puts i } # 1, 2, 3puts (1...10).count # 9puts (1..10).includes?(10) # TrueA range literal with ^ (from the end) is a .NET System.Range instead, which slices
arrays and strings.
Members
Section titled “Members”| Signature | Description |
|---|---|
Range.new(start: Int, end: Int, exclusive: Bool) |
Creates a range. |
start: Int |
The first value. |
end: Int |
The last value, or one past it when the range is exclusive. |
exclusive?: Bool |
true for a...b. |
last: Int |
The last value the range includes. |
count: Int |
The number of values in the range. |
includes?(value: Int): Bool |
Whether value lies within the range. |
to_array: Array[Int] |
The values of the range as an array. |
to_system_range: System::Range |
The equivalent System.Range, for slicing. |
to_s: String |
The range as written in source, e.g. "1..10". |
Only integer ranges are implemented. Ranges of other element types are [TBD] in the
literals specification.
RuntimeException
Section titled “RuntimeException”class Amethyst::Runtime::RuntimeException < ExceptionThe exception raised by raise "message" when no exception class is given.