A Hash is a dictionary-like collection of unique keys and their values. Also called associative arrays, they are similar to Arrays, but where an Array uses integers as its index, a Hash allows you to use any object type. You retrieve or create a new entry in a Hash by referring to its key.
Hashes in Ruby map keys to values using a hash table.
Any hashable object can be used as keys. However, it’s very common to use a Symbol
as it is generally more efficient in several Ruby versions, due to the reduced object allocation.
{ key1: "foo", key2: "baz" }