All right! We're getting into something that I've seen a lot in our data outputs on the console when I am debugging our applications, and I've long wondered what I was looking at. This exercise takes that on. This one is all about hashes. What's a hash, you say? Well, read on :).
Ruby calls them "hashes", other languages call them, "dictionaries". Zed says he uses both names, but what they are called doesn't really matter. What does matter is what they do when compared to arrays.
Arrays store their values in an ordered list, and you can reference and access those values by calling the index number from 0 to, well, whatever the last element in the array happens to be, and whatever that number is.
Instead of using numbers, we are using "symbols", which are effectively name tags, an they are easier to remember than trying to figure out where in an array something is.
So that's kinda cool, I can insert new items and give them a unique id and then if I print out the hash, I can see where it fits along with the number or id.
Go find the Ruby documentation for hashes and try to do even more things to them.
Find out what you can't do with hashes. A big one is that they do not have order, so try playing with that.
This is cool, it's an item I can definitely see using for an application like a phone book or contact lookup. I'm sure it can be used for a lot more than that, and I look forward to more options I can use going forward. What I like about it is the fact that the key can be an actual word, which is a lot more logical way to consider doing a lookup compared to remembering or finding a number in an array.