Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Hashes and Symbols

Nil: a Formal Introduction

What happens if you try to access a key that doesn't exist, though?

In many languages, you'll get an error of some kind. Not so in Ruby: you'll instead get the special value nil.

Along with false, nil is one of two non-true values in Ruby. (Every other object is regarded as "truthy," meaning that if you were to type if 2 or if "bacon", the code in that if statement would be run.)

It's important to realize that false and nil are not the same thing: false means "not true," while nil is Ruby's way of saying "nothing at all."

Report a Bug
If you see a bug or any other issue with this page, please report it here.