Other Pages

Expand All
Slides

Nil

Nil

nil is a magic object

There Is No Spoon

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

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

Fail Fast, Fail Often

Back to Learn To Code

If you find something that could be improved, please make a pull request or drop us a note via GitHub Issues (no technical knowledge required).

Source: https://github.com/RailsBridge-CapeTown