Skip to content
Justice Tech School

Symbols

A symbol is a lightweight unchangeable name like :ok. Symbols are used as hash keys.

Example
a = :ok
b = :ok
puts a.equal?(b), a.to_s, "ok".to_sym.inspect
puts %i[a b c].inspect

Result

true
ok
:ok
[:a, :b, :c]

Exercise

Convert to symbol.

"ok".

Quiz Test

Are two :ok the same object?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.