instance method
StringIO#close
() -> nil
close → nil
ext/stringio/stringio.c
View on GitHub ↗
static VALUE
strio_close(VALUE self)
{
StringIO(self);
RBASIC(self)->flags &= ~STRIO_READWRITE;
return Qnil;
}
Closes self for both reading and writing; returns nil:
Example
strio = StringIO.new strio.closed? # => false strio.close # => nil strio.closed? # => true strio.read # Raises IOError: not opened for reading strio.write # Raises IOError: not opened for writing
Related: StringIO#close_read, StringIO#close_write, StringIO.closed?.