instance method
StringIO#reopen
(::StringIO other) -> self
(::String other, ?::String mode_str) -> self
reopen(other, mode = 'r+') → self
ext/stringio/stringio.c
View on GitHub ↗
static VALUE
strio_reopen(int argc, VALUE *argv, VALUE self)
{
rb_io_taint_check(self);
if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) {
return strio_copy(self, *argv);
}
return strio_init(argc, argv, StringIO(self), self);
}
Reinitializes the stream with the given other (string or StringIO) and mode; see IO.new:
Example
StringIO.open('foo') do |strio| p strio.string strio.reopen('bar') p strio.string other_strio = StringIO.new('baz') strio.reopen(other_strio) p strio.string other_strio.close end
Output:
Example
"foo" "bar" "baz"