Why 'nil' is printing at the end?

puts “What’s up?”
print “Denisse”

This is Ruby Code, its giving this output:

What’s up?

why ‘nil’ is printing at the end?

1 Like

nil is Ruby-speak for nothing or end. Once your code stops running it outputs nil because there is nothing else to run.


So nil will be printed after every Ruby code works? any way to stop printing it?

Yes it will be printed for quite awhile, I haven’t worked with Ruby in awhile so I don’t remember how to remove it.

Okay… thanks for your quick Response! :slight_smile:

Welcome, just post again and I’ll help you to my best extent! :smile:

I just started Ruby and still have to go way more. So be ready for my doubts. Thank you Bud!

I would LOVE to know the same thing, Denise. I have the same question.

The only way I have found to get rid of ‘nil’ so far is to type an equal sign after print. However, once you type the equal sign after print it WILL show the quotation marks.

When i put the same code in eclipse, its not printing the “Nil”

so i think it has some thing to do with the codecademy interpreter.

1 Like

I’m having this issue too! I’m using Google Chrome and am now at the formal introduction to nil and I can’t move on while it continues to print to the console. I tried the equals sign, but that hasn’t helped.