From: Matthew Smillie Date: 2006-07-27T18:01:53+09:00 Subject: Re: Blocks question On Jul 27, 2006, at 9:46, Jon Leighton wrote: > Hi, > > I have written a script which sets up a new website on a server. > Obviously this involves a number of steps so I have written a method > which looks like so: > > def step(msg) > print msg + "... " > yield > puts "done" > end > > The idea being that you write something like: > > step("Creating site directory") { [mkdir code here } > > This all works fine, except for one thing. I would like the "Creating > site directory..." to show up *before* the yield takes place, and then > the "done" would appear afterwards. Currently the whole "Creating site > directory... done" appears only after the yield has completed, which > might make the user think something has gone wrong with longer > steps. I > don't understand why this happens, can anyone explain my options > please? I can't reproduce this on my machine, but it sounds very much like it's being caused by buffered output. This might work: def step(msg) print msg + "..." STDOUT.flush yield puts "done" end matthew smillie.