Ruby Tutorial: Symbols

Symbols

Ref. WGR Chapter 8, Section 8.2, Symbols and their uses

:a_symbol

There is only one representation of a given symbol in memory, so it really means "the thing named :a_symbol" to the ruby interpreter.

In Ruby, we prefer symbols over hardcoded globals or strings. They're very lightweight.

They also look better in code and are easier to type (by one character).