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#id2name

sym.id2name → string

Alias of #to_s

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_s #end_with? #inspect #encoding also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1