Skip to content
instance method

Symbol#to_s

() -> ::String
to_s → string

Returns a string representation of self (not including the leading colon):

Example
:foo.to_s # => "foo"

Related: Symbol#inspect, Symbol#name.

Ruby version changes

  1. 3.4
    • The string returned by Symbol#to_s now emits a deprecation warning when mutated, and will be frozen in a future version of Ruby. These warnings can be enabled with -W:deprecated or by setting Warning[:deprecated] = true. [Feature #20350]

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