What is the difference between Puts and Print statements?


I cant understand differnece between print and put


It's explained in the course:

The print command just takes whatever you give it and prints it to the screen. puts (for "put string") is slightly different: it adds a new (blank) line after the thing you want it to print.

If you need examples:

print "yili"
print "yolo"

will give:


puts "yili"
puts "yolo"

will give:



Thank You For Telling This.


I'm still not understanding how I'm supposed to reply to move forward


My code with puts "yili" puts "yolo" give me: yili yolo nil


Well my first reflex would be to tell you that there's something wrong with your code or how you read the result.

Can you post a screenshot of your code and the result?


Here the screenshot: http://imgur.com/IlntEEs

The code is just:

 print "yolo"
 puts "yili"

And that gives me the nil, every time I use print or puts. I searched through the forums and there's a lot of people with this problem, and they think is a codecademy bug.


nil is perfectly normal, it's what puts and print return, it just means "nothing".

print "yolo"
puts "yili"

will obviously output "yoloyili", since "print" does NOT output a new line after the text.


But what if I don't want to see the "nil" at the end? How can I make it stop printing nil?


It doesn't print it, it just returns it (and yes, it displays it, but if it was a "real" program, you wouldn't get "nil" in the output).

As far as I know, you can't get rid of it, but there are A LOT of things I don't know about Ruby.


it does not print it says you can not print


I still don't understand how to make that space even happen though? I'm an absolute beginner, someone please help! :confused:


I still wasn't understanding the explanation. Thank you for the examples, I finally got it ^__^



I was just stuck on this for almost 20 mins trying to figure it out
first I was only typing down,
what I was doing wrong is,
I wasn't telling the program what I was doing,
the right way to tell the program is,
put "Hello"
print "Hello!Hello!Hello"

see the difference first in I wasn't putting put or print that why the program didn't see what you were doing.