O'Reilly logo

The Ruby Way: Solutions and Techniques in Ruby Programming, Third Edition by André Arko, Hal Fulton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Symbols and Ranges

I hear, and I forget. I see, and I remember. I do, and I understand.

—Confucius

Two fairly Rubyesque objects are symbols and ranges. They are covered together in this chapter not because they are related but because there is not so much to say about them.

The Ruby concept of a symbol is sometimes difficult to grasp. If you are familiar with the concept of “atoms” in LISP, you can think of Ruby symbols as being similar. But rather than give a lengthy and abstruse definition, I will concentrate on what can be done with a symbol and how it can be used. After all, the question “What is a number?” could have a complex answer, but we all understand how to use and manipulate numbers.

Ranges are simpler. A range is simply ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required