Ruby Hashes

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”.

Have a look also at this tutorial.