I know this may seem like a really simple question, but it really bothers me that my puts keep generating "=> nil" and I scoured for an answer but could not find one. Thanks.
puts 'blink ' *4 blink blink blink blink => nil
I know this may seem like a really simple question, but it really bothers me that my puts keep generating "=> nil" and I scoured for an answer but could not find one. Thanks.
puts 'blink ' *4 blink blink blink blink => nil
You may want to use
p
instead ofput
s.p
prints and then returns the value.Hunter McMillen's answer is correct.
However, if you want a puts replacement that actually returns a non-nil value, I've created a gem called reputs.
Because that is the return value of
puts
:source: http://www.ruby-doc.org/core-1.9.3/IO.html#method-i-puts
Also, I assume this is just in
irb
? because callingputs
doesn't display its return value in normal applications.