Ruby Language Converting a Symbol to String


Example

Given a Symbol:

s = :something

The simplest way to convert it to a String is by using the Symbol#to_s method:

s.to_s
# => "something"

Another way to do it is by using the Symbol#id2name method which is an alias for the Symbol#to_s method. But it's a method that is unique to the Symbol class:

s.id2name
# => "something"