Working with Hashes
This lesson will discuss the "hash" data structure. Moreover, you'll learn how to get your hands dirty with them.
Dictionaries: look up one thing by another
Hashes are another very useful, and widely used kind of thing that can be used to store other objects.
Unlike arrays which are mere lists, Hashes are like dictionaries:
Imagine a real dictionary that translates from English to German. When you look up the English word “hello” then you’ll find the German “Hallo”. When you look up “one” then you’ll find “eins”, and so on. The authors of this dictionary have assigned a German word (a value) to an English word (the key).
Key | Value |
---|---|
Hello | Hallo |
one | eins |
Hashes work pretty much like this.
💡
A Hash assigns values to keys, so that values can be looked up by their key.
We also refer to a ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy