Code Editor
Learn
Hashes and Symbols

Symbol Syntax

Symbols always start with a colon (:). They must be valid Ruby variable names, so the first character after the colon has to be a letter or underscore (_); after that, any combination of letters, numbers, and underscores is allowed.

Make sure you don't put any spaces in your symbol nameā€”if you do, Ruby will get confused.

:my symbol # Don't do this! :my_symbol # Do this instead.
Report a Bug
If you see a bug or any other issue with this page, please report it here.