The Ruby hash tutorial
For complex collections, the hash data structure is a powerful tool in Ruby programs. Hashes are key/value-based and let you access data elements with more than a pure index, such as with arrays. Though we've briefly touched on hashes in the previous lessons, I want to give you a firm understanding of what hashes are and how they can be used.
Essentially, a hash is a key/value pair collection. In an array, each element is a single item such as a number or word whereas in a hash, each element has two items, and includes a value and a key associated with it.
Sometimes, the value itself can be another collection like an array or a hash.
The hash code example
Let's start by creating a hash:
positions = { first_base: "Chris Carter", second_base: "Jose Altuve", short_stop: "Carlos Correa" }
When you run this code, you can see the hash, where the keys are mapped to their respective values:

In the written code, I placed...