Symbols Name
x = 1 xsymbol = :x# from www . j av a2s . c o m def amethod( somearg ) p( somearg ) end # Test 1 amethod( x ) amethod( :x ) amethod( eval(:x.id2name))
Here, id2name is a method of the Symbol class.
It returns the name or string corresponding to the symbol.
The to_s method would perform the same function.
Ruby's eval method can evaluate talks within strings.