Nil

nil is a magic object

There Is No Spoon

nil is the object that means "there is no object"

Q: What is the sound of one hand clapping?

A: nil

Experiment

fruit = "apple"
fruit = nil
fruit.reverse

Read the error!

Errors are good

They tell you

Interpret this error:

fruit.reverse
NoMethodError: undefined method `reverse' for nil:NilClass

null pointer errors

If You're Going To Fail...

Two philosophies:

Which idea is better?

Why or why not?

Fail Fast, Fail Often

 Previous Lesson Next Lesson 

Outline

[menu]

/