How to convert a string to a symbol?

Is there any possible to convert a string to a symbol, such as
“foo”->:foo?

‘foo’.to_sym

Subject: How to convert a string to a symbol?
Date: sab 11 ott 14 10:26:24 +0800

Quoting xiaopeng ([email protected]):

Is there any possible to convert a string to a symbol, such as “foo”->:foo?

String#to_sym

Carlo

foo.to_sym

Yep!

“mystring”.to_sym
-> :mystring

On Sat, Oct 11, 2014 at 7:26 AM, xiaopeng [email protected] wrote:

Is there any possible to convert a string to a symbol, such as “foo”->:foo?

Hint: the documentation is your friend:

so quickly, thanks a lot to you and other guys:)

You can use to_sym

“foo”.to_sym
=> :foo