Hashes
suggest changeIntroduction
A hash is a dictionary-like collection of unique keys and their values. It is sometimes called an associative array. An array is indexed by integers; a hash is indexed by any object. Look up or store an entry by its key.
Syntax
{ first_name: "Noel", second_name: "Edmonds" }{ :first_name => "Noel", :second_name => "Edmonds" }{ "First Name" => "Noel", "Second Name" => "Edmonds" }{ first_key => first_value, second_key => second_value }
Remarks
Hashes in Ruby map keys to values using a hash table.
Any object can be a key. Keys that compare equal must return the same hash value. Symbols are common because each name is one interned object.
{ key1: "foo", key2: "baz" }
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents