From: Robert Gleeson Date: 2009-12-12T13:29:57+09:00 Subject: Re: Redirecting standard output Robert Klemme wrote: > On 12/11/2009 05:30 PM, Robert Gleeson wrote: >> >> So what gives? > > I suggest you look again at my earlier posting (the one with the "date" > example) and / or look at the documentation. There *is* a difference > between reassigning and using #reopen - and it is significant. > > Cheers > > robert Yup, I've acknowledged the difference myself in all my previous posts. I just couldn't understand your second argument, but I think I know what you mean from playing around in IRB. Reassignment will create a new object.. so # $stdout references a new object - foo references old. foo = $stdout $stdout = File.open 'foo', 'w' # $stdout.reopen will keep the same object identity.. # So all previous references will persist. foo = $stdout $stdout.reopen 'foo', 'w' Understood now. I can sleep. - Rob -- Posted via http://www.ruby-forum.com/.