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.

"apple"  # transient and mutable
:apple   # permanent and immutable

Hardcore Rubyists 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).

In Alex's Humble Opinion

 Previous Lesson Next Lesson 

Outline

[menu]

/