Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

StringIO.open

StringIO.open(string=""[, mode]) {|strio| ...}

Equivalent to StringIO.new except that when it is called with a block, it yields with the new instance and closes it, and returns the result which returned from the block.

See also .new #binmode #close also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0