Reputation: 26679
puts
statement in ruby automatically adds a new line, how do I avoid it?
Upvotes: 118
Views: 69035
Reputation: 1618
$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?"
Upvotes: 7
Reputation: 463
Also, you'll need to append "\r" at end of line to indicate "carriage return" and do next print at beginning of current line
Upvotes: 8
Reputation: 230286
Use print
instead.
You may want to follow it up by STDOUT.flush
.
Upvotes: 148