Mark Sparshatt wrote:
> Hal Fulton wrote:
> 
>> I've been playing with StringIO, and I've found that it doesn't inherit
>> from IO.
>>
>> I had thought this would be natural, as it would in theory permit us to
>> use a StringIO wherever an IO is used.
>>
> Well as long as the code doesn't check the class of it's parameters and 
> just relies on duck typing it should still be possible to use a StringIO 
> in place of an IO object.
> 
> 
> However, IIRC there are parts of the core language that do explicitly 
> check that they're receiving a string, for speed reasons, so having 
> StringIO inherit from String makes more sense.

I tried a StringIO with #select and it whined at me.

But apparently it doesn't even inherit from String, but from Data:

irb(main):001:0> require "stringio"
=> true
irb(main):002:0> StringIO.ancestors
=> [StringIO, Enumerable, Data, Object, Kernel]



Hal