...

/

Working with Hashes

Working with Hashes

Learn about the Hash data structure.

Dictionaries

Hashes, or Hash objects, are another useful and widely used object that can be used to store other objects.

Unlike arrays that are mere lists, Hash objects are like dictionaries.

We can use them to look one thing up through another thing. We can look a value up from a hash using a key, or retrieve the value associated with the key.

Imagine a real dictionary that translates from English to German. When we look up the English word “hello,” we find the German “hallo”. When we look up “one,” we find “eins,” and so on. The authors of this dictionary have assigned a German word (value) to an English word (key).

English Keys and German Values

Key Value
hello hallo
one eins
...