Ruby Intro To Hashes Lab


  1. Build simple hashes.
  2. Build nested hashes.
  3. Access and modify data stored in a hash.
  4. Add new data to a hash.


  1. Fork and clone this lab and run the test suite with the learn test command. Pay attention to the test suite for this lab. The instructions and comments are designed to help you get the tests to pass.

  2. The test requires you to create a method called #new_hash that creates and returns a new, empty hash.

  3. The second test requires you to build a method called #actor that creates and returns a hash with a certain actor's name. Read the test output by entering rspec or learn test—this is where you will find the necessary information for passing the test!

  4. The next series of tests will require you to build methods that build up a nested hash, one layer (or "level") at a time, in a similar way to how we built our epic_tragedy hash in the previous lesson. Read the test output very carefully; it will guide you through building the necessary methods. At the end of the exercise, your multidimensional monopoly hash should look like this:

monopoly =  {

Don't Forget!

Remember to use binding.pry to help you get inside your methods and understand what is going on if you need to debug. Remember to google questions that you have if you get stuck and remember to ask questions!


  1. What is a Hash in Ruby?
  2. Ruby Documentation on Hashes
Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us