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


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 "
    print "b is equal to a "

OUTPUT: a is less than b nil

It annoys me, and i want to know how to get it removed


Check this thread,It might be a help.


So i can say:

variable = gets.chomp.to_i



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


Could you send me a link of that?


My first post ? You might have checked it though.


Oh yeah sorry :grin:


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


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