The true, false, and nil Objects

Let's learn about true, false, and nil objects.

There are a few more objects to mention that we’ll see quite frequently. First are true and false.

The true and false objects

The true and false objects are rather straightforward: the true object represents truth, while false represents the opposite.

In other words, true and false are also things, just like the examples of numbers and strings we saw earlier. We can assign them to variables, pass them around, and use them in other ways. They’re fairly simple but useful.

The nil object

The third object, nil, represents nothing, or the absence of things. We’ll see later that every operation (method) in Ruby always returns exactly one thing (one object), and that’s why there needs to be something that represents nothing.