Why 'nil' is printing at the end?


#1

puts "What's up?"
print "Denisse"

This is Ruby Code, its giving this output:

What's up?
Denissenil

why 'nil' is printing at the end?


#2

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


#3

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


#4

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.


#5

Okay.. thanks for your quick Response! :slight_smile:


#6

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


#7

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


#8

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


#9

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.


#10

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.


#11

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.