Ruby/String/Convert to Symbol
Материал из Wiki.crossplatform.ru
(Различия между версиями)
Версия 17:10, 26 мая 2010
The value of the string, not its name, becomes the symbol
play = "this is a test".intern
To convert a string into a symbol (Symbol class), use either the to_sym or intern methods
"name".intern # => :name "name".to_sym # => :name