Ruby Hashes

Watch out! This tutorial is over 8 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

Ruby hashes are similar to maps or dictionaries in other languages. They are essentially arrays whose subscripts are not limited to integer values. You can create them with the curly-bracked list notation shown below, but you can also assign to a subscript expression to add members. It’s not at all unreasonable to create a hash with empty brackets, then add members using subscripting.

Method names may end in ?, hence the name of the has_key? method. This suggests a the method is a test which returns a boolean value. Such methods are sometimes known as “predicates”.

z = { 'mike' => 75, 'bill' => 18, 'alice' => 32 }
z['joe'] = 44
print z['bill'], " ", z['joe'], " ", z["smith"], "\n"
print z.has_key?('mike'), " ", z.has_key?("jones"), "\n"

Have a look also at this tutorial.