December 2014
Beginner
336 pages
7h 41m
English
Now I have to hurt you with another container you can use, because once you learn this container a massive world of ultra-cool will be yours. It is the most useful container ever: the dictionary.
Ruby calls them “hashes”, which is short for “hashmaps.” Other languages call them “dictionaries.” I tend to use both names, but it doesn’t matter. What does matter is what hashs do when compared to arrays. You see, an array lets you do this:
Exercise 39 Ruby Session
?> things = ['a', 'b', 'c', 'd'] => ["a", "b", "c", "d"] >> puts things[1] b => nil >> things[1] = 'z' => "z" >> puts things[1] z => nil >> things => ["a", "z", "c", "d"]
You can use numbers to “index” into a array, meaning ...
Read now
Unlock full access