From: Caleb Clausen Date: 2010-04-30T06:24:30+09:00 Subject: Re: Use of STDOUT.flush after puts On 4/29/10, hemant wrote: > Ruby standard library uses IO#reopen many places on STDOUT. I am not > saying since Ruby standard library does that, it has to be best Not necessarily. There are some dusty corners in stdlib. If stdlib does this, it may be a bug; can you give examples? The one place I know of is the cgi library, which reopens STDIN/OUT/ERR as part of the process of purifying the environment of the cgi server process. Other servers might do the same and it would be appropriate there as well. I guess the other case where it would be necessary is if you want to change the STDIN/OUT/ERR seen by subprocesses. In other cases that I know of, modifying STDIN/OUT/ERR is not a good idea.... > How can reopen change the class btw? Ruby is not a class oriented language > btw. Check out this code. No other method in all of ruby has this behavior. p $stderr.class #=>IO f=File.new "foo","w" $stderr.reopen(f) p $stderr.class #=>File