Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




Ruby Programming
Previous Page Home Next Page

Ranges as Intervals

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.
Ruby Programming
Previous Page Home Next Page

  Published under the terms of the Open Publication License Design by Interspire