From: Charles Oliver Nutter Date: 2011-10-26T06:30:59+09:00 Subject: [ruby-core:40375] Re: [ruby-trunk - Feature #5479] import StringIO into core, add String#to_io On Tue, Oct 25, 2011 at 1:35 PM, Aaron Patterson wrote: > On Wed, Oct 26, 2011 at 02:22:21AM +0900, Haase, Konstantin wrote: >> My main request was to add String#to_io, as Aaron described, so this protocol can actually be used. This is the only reason why I proposed moving StringIO to core. We could also add String#to_io as a monkey-patch to String in stringio in the stdlib. Oops, I totally spaced that off. Yeah, that's easy enough. > I really like this idea, but I'm kind of afraid of the consequences. > StringIO isn't a subclass of IO, and some things in ruby call `to_io` > then check the return type: ... > I'm not sure which is best: convert StringIO to subclass IO, or find > these places that call `to_io` and fix them. ��Not to mention, how do we > "fix" the above example? ��What does `exists?` mean in terms of a > StringIO? I no longer like the idea myself :) It feels too much to me like to_str and to_ary and seems to have the same "internals" implications they do: that they'll return a subclass of that type. - Charlie