1. Computing
Send to a Friend via Email

Building Hashes


1 of 5

Building Hashes

A hash is an associative array. Instead of using numerical indexes, any object (but typically symbols) can be used. They can be both a fast way to retrieve an object based on a key, and a convenient key/value store. There's no doubt, hashes are one of the most used types in Ruby.

But how do you build a Hash? How do you insert data into it other than assigning keys to values one at a time? There are a few methods of building hashes you should know about.

©2014 About.com. All rights reserved.