"Gregory Brown" <gregory.t.brown / gmail.com> wrote/schrieb <b37300880708121526j299f1ed3t3b7e45851d9ec0e9 / mail.gmail.com>:

> Gotcha.  IMO, there is no need for the abstraction if it's limited to
> these two functions.
> You're only talking about a couple lines of code, and your need for
> this won't expand much over time, it seems.

Nevertheless, if Ruby had explicit references (does it?), it would be
simple enough to have just one function instead of the original both
ones, e.g. with ``()'' as a placeholder for a hypothetical
dereferencing operator:

def with_stream_to_string(stream)
  ()stream, tmp = StringIO.new, ()stream
  yield
  ()stream, tmp = tmp, ()stream
  tmp.rewind
  tmp.read
end

Regards
  Thomas