Creating a symbol from a string

39 views
Skip to first unread message

Yves Cloutier

unread,
Jan 28, 2019, 8:34:12 PM1/28/19
to Crystal
Hello,

Is it possible to create a symbol from a string.

For example "a_string".to_symbol  ?

I've looked through the String API but couldn't find any method. 

Ary Borenszweig

unread,
Jan 29, 2019, 4:42:08 AM1/29/19
to crysta...@googlegroups.com
Hi!

No, it's not possible.

--
You received this message because you are subscribed to the Google Groups "Crystal" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crystal-lang...@googlegroups.com.
To post to this group, send email to crysta...@googlegroups.com.
Visit this group at https://groups.google.com/group/crystal-lang.
To view this discussion on the web visit https://groups.google.com/d/msgid/crystal-lang/6ce7cd79-7b9f-400e-b734-4134498e2449%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yves Cloutier

unread,
Jan 29, 2019, 9:42:06 AM1/29/19
to crysta...@googlegroups.com
Ok thanks. Ill try to do it using a macro.

You received this message because you are subscribed to a topic in the Google Groups "Crystal" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/crystal-lang/xVEs5QypkfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to crystal-lang...@googlegroups.com.

To post to this group, send email to crysta...@googlegroups.com.
Visit this group at https://groups.google.com/group/crystal-lang.

Ary Borenszweig

unread,
Jan 29, 2019, 9:44:03 AM1/29/19
to crysta...@googlegroups.com
My advise is to not use symbols, you can probably just use strings for your use case.

Yves Cloutier

unread,
Jan 29, 2019, 10:21:20 AM1/29/19
to crysta...@googlegroups.com
Thanks for your suggestion Ary

Reply all
Reply to author
Forward
0 new messages