Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Basics (Retired) How Ruby Works The Ruby Programming Language

What does 'nil' signify?

I just watched the first intro to Ruby video and Jason doesn't explain what the nil is in the result when the puts is run. What is nil?

irb > puts "Burrito Continent!"
Burrito Continent!
=> nil

2 Answers

Daniel Crews
Daniel Crews
14,008 Points

Every method call on an object returns a value, sometimes that value is a result of an expression evaluation, sometimes it is an explicit return, sometimes it is simply nothing. nil is nothing. In the expression above, the puts method performs its action, which is to print to the output. It performs no evaluation and returns nothing at all.

nil is a ruby object that represents quite literally "nothing".

Why does the nil get printed after running the puts?