Puts and Print


#1

puts "Hello"
print "Hi"

i am getting the output as

Hello

Hinil

Can i know the reason why nil is being printed in the later part of print ?


#2

Because the console in the course is printing out what the last instruction evaluates to (print returns nil). In my opinion it shouldn’t because it seems to confuse many people.

If you want a better distinction between the last return and the output, you can try your code here, it prints the output normally and the return is shown in green.

labs repl.it


#3

Thanks for the response :smile: