Ruby: My Gem
1 min readAug 19, 2020
--
Ruby symbols & strings
Strings are used for the Data while the Symbols are used as Identifiers.
Symbols
One of the most common uses of the symbols is to represent methods and instance variable names.
:symbol_name #syntax
hash = {a: 1, b: 2, c: 3} #can be used as hash keys
A symbol is immutable, increases the speed, and has unique object id.. (reference)
Symbols are not a pointer to values, they are values themselves
to_sym (Convert to a symbol)
to_s (Convert to a string)