Skip to content

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

instance method

Symbol#to_s

sym.to_s → string

Returns the name or string corresponding to sym.

Example
:fred.id2name   #=> "fred"
:ginger.to_s    #=> "ginger"

Note that this string is not frozen (unlike the symbol itself). To get a frozen string, use name.

See also #to_proc #to_sym #to_json #upcase also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1