A final use of the versatile range is as an interval test:
seeing if
some value falls within the interval represented by the range.
This is done using
===
, the case equality operator.
(1..10) === 5
|
� |
true
|
(1..10) === 15
|
� |
false
|
(1..10) === 3.14159
|
� |
true
|
('a'..'j') === 'c'
|
� |
true
|
('a'..'j') === 'z'
|
� |
false
|
The example of a case expression on page 81 shows this
test in action, determining a jazz style given a year.