Chapter 7. Built-in essentials

 

In this chapter

  • Literal object constructors
  • Syntactic sugar
  • “Dangerous” and/or destructive methods
  • The to_* family of conversion methods
  • Boolean states and objects, and nil
  • Object-comparison techniques
  • Runtime inspection of objects’ capabilities

The later chapters in this part of the book will cover specific built-in classes: what they are, what you can do with them, and what methods their instances have. This chapter will discuss a selection of topics that cut across a number of built-in classes.

It’s more than that, though: it’s also a kind of next-generation Ruby literacy guide, a deeper and wider version of chapter 1. Like chapter 1, this chapter has two goals: making it possible to take a certain amount of material for granted in later chapters, where it will arise in various places to varying degrees; and presenting you with information about Ruby that is important and usable in its own right. Throughout this chapter, you’ll explore the richness that lies in every Ruby object, as well as some of the syntactic and semantic subsystems that make the language so interesting and versatile.

The chapter moves through a number of topics, so it’s probably worth having a look in advance at what you’re going to see. Here’s a lightly annotated summary:

7.1. Ruby’s literal constructors

7.2. Recurrent syntactic sugar

7.3. Bang (!) methods and “danger”

7.4. Built-in and custom to_* (conversion) methods

7.5. Boolean states, boolean objects, and nil

7.6. Comparing two objects

7.7. Inspecting object capabilities

7.8. Summary