From: uncutstone wu Date: 2006-05-18T02:16:06+09:00 Subject: Re: Capturing stdout Mark Volkmann wrote: > Here's another alternative. > > # Create a string object to receive the output. > dest = '' > > # Add a write method to this string object. > def dest.write(data); self << data; end > > old_stdout, $stdout = $stdout, dest > > # Invoke code that uses puts. > > # Restore stdout. > $stdout = old_stdout I think this is what duck type means. It's really a good example of duck type, isn't it? Best regards. uncutstone -- Posted via http://www.ruby-forum.com/.