Skip to content
instance method

StringIO#close

() -> nil
close → nil

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?.

See also #binmode #closed? .open #closed_read? also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0