How to print something without a new line in ruby

puts statement in ruby ​​automatically adds a new line, how can I avoid it.

+79
ruby
Jan 04 2018-12-12T00:
source share
3 answers

Use print instead. You can trace it to STDOUT.flush .

+106
Jan 04 2018-12-12T00:
source share

In addition, you need to add "\ r" at the end of the line to indicate "carriage return", and do the next print at the beginning of the current line

+4
May 17 '13 at 3:21
source share
 $stdout.sync = true 100.times do print "." sleep 1 end 

"How can I use" puts "on the console without breaking a line in ruby ​​on rails?"

+2
Nov 10 '15 at 13:23
source share



All Articles