[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: sleep command in iterators (silly n00b toy question

Peña, Botp

9/6/2003 8:44:00 AM


Gavin Sinclair [mailto:gsinclair@soyabean.com.au] helpfully explained:

> > Hey! It works! That's so neat, thanks!
>
> > Any chance you'd care to explain a little bit, what I just
> did??? ;-)
>...
> Anyway, to answer your real question, IO objects have a
> "sync" method which synchronises their output, instead of
> buffering it.
>
> Another way to ensure your output is not buffered is to
> explicitly "flush" it. This may better style than using
> "sync" because it doesn't interfere with other parts of the program.
>
> def print_dots(io=STDOUT)
> 25.times do
> io.print "."
> io.flush
> sleep 1
> end
> io.puts
> end

cool.
never thought about flush. Can you put in wiki, sir Gavin.

>
> HTH,

it helped indeed.

> Gavin

kind regards -botp