In order to understand a programming language, you have to
know what kinds of data it can manipulate and what it can do with that
data. This chapter is about the values manipulated by Ruby programs. It
begins with comprehensive coverage of numeric and textual values. Next, it
explains arrays and hashes—two important data structures that are a
fundamental part of Ruby. The chapter then moves on to explain ranges,
symbols, and the special values
nil. All Ruby values are objects, and this
chapter concludes with detailed coverage of the features that all objects
The classes described in this chapter are the fundamental datatypes of the Ruby language. This chapter explains the basic behavior of those types: how literal values are written in a program, how integer and floating-point arithmetic work, how textual data is encoded, how values can serve as hash keys, and so on. Although we cover numbers, strings, arrays, and hashes here, this chapter makes no attempt to explain the APIs defined by those types. Instead, Chapter 9 demonstrates those APIs by example, and it also covers many other important (but nonfundamental) classes.
Ruby includes five built-in classes for representing numbers, and the standard library includes three more numeric classes that are sometimes useful. Figure 3-1 shows the class hierarchy.
Figure 3-1. Numeric ...