Hashes : In Layman’s Term

One key feature of Ruby on Rails is Hashes. Now, just try to think of hashes like a PARTY. The party is a potluck occasion, naturally, each guest is required to bring an item or food. You will then need a LIST of all the guests, now this can be managed as an array. But you will also have to make a way to monitor all types of food that is being brought to the event. And to explain it further, you will want to know who is bringing the pasta, who will be bringing the fried chicken and so on. This is where Hashes come in. You will use hash to store value pairs or key pairs, this in turn will enable you to store that particular data. If for example Amanda is the “key”, and she brought cake, the variable stored and accessed by the key will be “cake”.

Leave a comment

* - Required fields