Why does the ruby program always print "nil" after printing something


#1


It is not a regular problem, but it is annoying me. When i print something, it always prints "nil" after that (no spaces between). You can see an example of it below:


a = 10
b = 11

if a < b
    print "a is less than b "
elsif b < a
    print "b is less than a "
else
    print "b is equal to a "
end

OUTPUT: a is less than b nil

It annoys me, and i want to know how to get it removed
PLEASE HELP ME!


#2

Check this thread,It might be a help.
https://www.codecademy.com/en/forum_questions/52191f0babf82149260004e7


#3

So i can say:

variable = gets.chomp.to_i

?


#4

Try that ?(But It will have nil at the end) ha!
As I posted a url of a post that describes the reason.


#5

Could you send me a link of that?


#6

My first post ? You might have checked it though.


#7

Oh yeah sorry :grin:


#8

It's all good! :wink: :thumbsup:


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.