From: Kevin Smith Date: 2001-01-01T02:24:45+09:00 Subject: [ruby-talk:8428] Re: string like istringstream (was: A bug inruby) jmichel@schur.institut.math.jussieu.fr wrote: > On another topic, is there a way in ruby to have a string behave as a file > (something like the 'istringstrem' class of C++ ?) There was a discussion of this a few weeks ago. Since Ruby is dynamically typed, Strings and Files can behave the same (and thus be interchangable) even if they do not inherit from each other. For eample: stream.each_line do | line | puts ">" + line end This will work whether stream is a File or a String. If there are other operations that you would like String to support (like lineno or seek) you would just have to create a subclass of String that implements those methods. This should definitely go in the FAQ. Kevin