News for hackers. Stuff that matters.
Re:Why Ruby Has Symbols by matheusmoreira on Thursday April 14, 2022 @02:34PM (#31031309)
> symbols are somewhat limited in what they can be made of

Only in the unquoted literal syntax. The :symbol form follows Ruby's usual identifier rules but there's also a :"quoted symbol" syntax. You can also send :to_sym or :intern to any string and it will be converted to a symbol.

https://ruby-doc.org/core/String.html#method-i-to_sym

> This can also be used to create symbols that cannot be represented using the :xxx notation.

  'cat and dog'.to_sym   #=> :"cat and dog"

There are no comments on this comment yet.