How to print something without a new line in ruby
RubyRuby Problem Overview
puts
statement in ruby automatically adds a new line, how do I avoid it?
Ruby Solutions
Solution 1 - Ruby
Use print
instead.
You may want to follow it up by STDOUT.flush
.
Solution 2 - Ruby
Also, you'll need to append "\r" at end of line to indicate "carriage return" and do next print at beginning of current line
Solution 3 - Ruby
$stdout.sync = true
100.times do
print "."
sleep 1
end
"How can I use “puts” to the console without a line break in ruby on rails?"