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 its purpose/possible uses in Ruby? Just hoping to clear up my confusion.
相关问题
- What is the best way to do a search in a large fil
- How to specify memcache server to Rack::Session::M
- In what practical case bool(std::ifstream) != std:
- Why am I getting a “C compiler cannot create execu
- reference to a method?
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- uninitialized constant Mysql2::Client::SECURE_CONN
- ruby - simplify string multiply concatenation
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.