Nil in Ruby

2 exercises

About Nil

Nil is an English word meaning "nothing" or "zero". In Ruby, nil is used to express the absence of an object. In other programming languages, null or none values may play a similar role.

# I do not have a favorite color
favorite_color = nil

Ruby gives any instance variable the default value of nil when it is first encountered, until it is set otherwise.

Edit via GitHub The link opens in a new window or tab

Learn Nil

Practicing is locked

Unlock 1 more exercise to practice Nil