For our code example, we are going to iterate over a hash data set. You will learn about hashes in-depth in future lessons, but for now, just know that hashes are a key/value-based data structure. Here is a basic nested hash:
teams = { "Houston Astros" => { "first base" => "AJ Reed", "second base" => "Jose Altuve", "shortstop" => "Carlos Correa" }, "Texas Rangers" => { "first base" => "Prince Fielder", "second base" => "R. Odor", "shortstop" => "Elvis Andrus" } }
This is a nested key/value pair structure where we have a collection called teams. There are two teams inside this collection, namely, Houston Astros and Texas Rangers. Inside each of these teams, there are positions and players.
Our program ...