From: daz Date: 2004-04-30T07:29:02+09:00 Subject: Re: Should StringIO support to_str ? Hugh Sasse wrote: > Gavin Sinclair wrote: > > > #string > > That's better, but I don't see the part with which I initialized. The default open mode is 'w+', so append occurs at file pos = 0. So, like an existing file, your init. string gets overwritten. try StringIO.new("text", 'a+') # or 'a' (Not defending, just observing ;) Aside: StringIO in CVS ( ruby 1.9.0 (2004-04-27) [i586-bccwin32] ) #----- require 'stringio' sio = StringIO.new STDOUT.reopen(sio) #----- C:/TEMP/rb5226.TMP:5:in `reopen': cannot convert StringIO into String (TypeError) (I appreciate IO#reopen is undergoing changes; thanks)