Ruby将字符串转换为符号

示例

给定一个String:

s = "something"

有几种方法可以将其转换为Symbol:

s.to_sym
# => :something
:"#{s}"
# => :something