tags:

views:

390

answers:

1

I think I understand StringIO somewhat as being similar to java's StringBuffer class, but I don't really understand it fully. How would you define it and it's purpose/possible uses in ruby? Just hoping to clear up my confusion.

Thanks

+8  A: 

no, StringIO is more similar to StringReader/StringWriter than StringBuffer.

In Java StringBuffer is the mutable version of String (since String is immutable).

StringReader/StringWriter are handy classes meant to be used when you want to fake file access . You can read/write in a String with the same stream-oriented interface of Reader/Writer: it is immensely useful in unit testing.

dfa
Thanks. That cleared it up for me. I would upvote your answer, but I need more rep :)
John Dyer