Skip to content
instance method

StringIO#string=

(::String str) -> ::String
string = other_string → other_string

Replaces the stored string with other_string, and sets the position to zero; returns other_string:

Example
StringIO.open('foo') do |strio|
  p strio.string
  strio.string = 'bar'
  p strio.string
end

Output:

Example
"foo"
"bar"

Related: StringIO#string (returns the stored string).

See also #string #sync #size #sync= also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0