Symbols

Overview

  • A symbol looks like :this_is_a_symbol
  • starts with a colon :
  • can be used in similar places as a string but tells the interpreter and programmers that it means “the thing named :this_is_a_symbol” rather than text
  • In ruby, we prefer symbols over hardcoded globals or strings. They’re very lightweight.

Try typing this in IRB

:rwanda

:ruby_on_rails

Exercises