From: Robert Dober Date: 2010-04-30T02:26:21+09:00 Subject: Re: Use of STDOUT.flush after puts On Thu, Apr 29, 2010 at 2:31 PM, hemant wrote: > On Thu, Apr 29, 2010 at 1:28 PM, Robert Dober wrote: >> On Thu, Apr 29, 2010 at 9:16 AM, Siep Korteling wrote: >> >>> Instead of STDOUT.flush-ing multiple times, you can set STDOUT.sync = >>> true once. >> >> And, please, instead of using STDOUT, please use $stdout, this allows >> your users to mock stdout to somewhere else *without* getting constant >> redefinition warnings. > > > One can always use IO#reopen if one wants to redirect the output > somewhere. I still prefer constant declaration more than global > variable. > Hmm, can you? I am not that sure, here is the behavior I was thinking about: def with_stdout stdout, &blk original_stdout = $stdout $stdout = stdout blk[] ensure $stdout = original_stdout end R.