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 trialA X
12,842 PointsWhat 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
14,008 PointsEvery 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.
David Cisneros
10,472 Pointsnil is a ruby object that represents quite literally "nothing".
A X
12,842 PointsWhy does the nil get printed after running the puts?