4 ms·
> 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 ther
by matheusmoreira 5y ago
> 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 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"