What happens if we want to work with many pieces of data in ruby? A collection? A series of numbers that we need to put in ascending order? Or a list of names sorted alphabetically? How does Ruby manage that? Ruby gives us two tools: hashes and arrays. Which one should we use? We will dive in to both in this post!
The official Ruby documentation definition of arrays, you’ll see that an array is defined as an ordered, integer-indexed collection of objects. What a mouthfull! Lets examine.
A Hash is a collection of key-value pairs like this: "first_name" => "Mike". It is similar to an Array, except that indexing is done via arbitrary keys of any object type, not an integer index.
Hashes and Arrays have some key differences: