Skip to content

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

instance method

String#to_s

to_s → self or string

Returns self if self is a String, or self converted to a String if self is a subclass of String.

String#to_str is an alias for String#to_s.

See also #to_r #tosjis #tolocale #to_str also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0