From: Robert Klemme Date: 2010-04-30T16:09:40+09:00 Subject: Re: Use of STDOUT.flush after puts 2010/4/30 Charles Oliver Nutter : > On Thu, Apr 29, 2010 at 4:24 PM, Caleb Clausen wrote: >> On 4/29/10, hemant wrote: >>> 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 > > This is a really nasty feature not a lot of people know about. It's > not possible for us to support in JRuby because the underlying object > can't actually change class: That's true, instances which change their class - this is problematic. > I'm of the opinion that .reopen should be discouraged in general. IMHO that is a bad idea because this is the standard way how you redirect stderr, stdin and stdout for child processes - at least on POSIX systems. Any program that wants to do something similar like IO.popen or just wants to prevent the child's stdout to clutter its own output depends on the ability to do this. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/