Re: counter

[email protected] wrote:

6
7
8
9
10
etc…

but I don’t want a linebreak after the counter is displayed. I want it
just to keep refreshing itself, basically. Am I missing something
with puts or print or p? Any ideas?

$stdout.sync = true
20.times do |_counter|
counter = _counter.to_s
print counter + “\b” * counter.size
sleep 1
end

FYI: puts and p both add “\n” to the output if it is not yet there.

Gennady.

Gennady B. wrote:

[email protected] wrote:

(snip)

end

FYI: puts and p both add “\n” to the output if it is not yet there.
printf doesn’t

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs