|Range, Number| -> Bool
Returns true if the provided number is within the range, and false otherwise.
|Range, Range| -> Bool
Returns true if the provided range is entirely containd within the range, and false otherwise.
(10..20).contains 15
# -> true
(200..=100).contains 100
# -> true
x = 1..10
x.contains -1
# -> false
(10..20).contains 14..18
# -> true
(100..200).contains 50..250
# -> false
|Range| -> Int
Returns the end
value of the range.
(50..100).end()
# -> 100
(10..0).end()
# -> 0
|Range, Number| -> Range
Returns a copy of the input range which has been 'expanded' in both directions
by the provided amount. For an ascending range this will mean that start
will
decrease by the provided amount, while end
will increase.
Negative amounts will cause the range to shrink rather than grow.
(10..20).expanded 5
# -> 5..25
(10..20).expanded -2
# -> 12..18
(5..-5).expanded 5
# -> 10..-10
(5..-5).expanded -5
# -> 0..0
(5..-5).expanded -10
# -> -5..5
|Range, Range| -> Range
Returns a range representing the intersectin region of the two input ranges.
If there is no intersecting region then null
is returned.
(10..20).intersection 5..15
# -> 10..15
(100..200).intersection 250..=150
# -> 150..200
(0..10).intersection 90..99
# -> null
|Range| -> Bool
Returns true if the range has a defined end which is inclusive.
(10..20).is_inclusive()
# -> false
(1..=10).is_inclusive()
# -> true
(100..).is_inclusive()
# -> false
|Range| -> Int
Returns the start
value of the range.
(50..100).start()
# -> 50
(10..0).start()
# -> 10
|Range, Number| -> Range
Returns the union of the range and a provided number.
If the number falls outside of the range then the resulting range will be expanded to include the number.
|Range, Range| -> Range
Returns the union of two ranges.
The resulting range will encompass all values that are contained in the two ranges, and any values that lie between them.
(0..10).union 5
# -> 0..10
(0..10).union 99
# -> 0..100
a = 10..20
b = 40..50
a.union b
# -> 10..50