Chapter 3. Ruby's Building Blocks: Data, Expressions, and Flow Control

Computer programs spend nearly all their time manipulating data. We type in words, phrases, and numbers; listen to music; and watch videos, while the computer performs calculations, makes decisions, and relays information to us. To write computer programs, it's essential to understand the basics of data and its manipulation.

This chapter looks at some of the basic forms of data that Ruby supports, along with how to work with and manipulate them. The topics covered in this chapter will provide the majority of the foundation of knowledge on which your future Ruby programs will be developed.

Numbers and Expressions

At the lowest level, computers are entirely number-based, with everything ...

Get Beginning Ruby: From Novice to Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.