To convert a string into a symbol (Symbol class), use either the to_sym or intern methods : Convert to Symbol « String « Ruby






To convert a string into a symbol (Symbol class), use either the to_sym or intern methods


"name".intern # => :name
"name".to_sym # => :name

 

Related examples in the same category

1.The value of the string, not its name, becomes the symbol