Giter Site home page Giter Site logo

ruby-intro-to-hashes-lab's Introduction

Intro to Hashes Lab

Objectives

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

Instructions

  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 =  {
  :railroads=>
  {
    :pieces=>4,
    :rent_in_dollars=>
    {
      :one_piece_owned=>25,
      :two_pieces_owned=>50,
      :three_pieces_owned=>100,
      :four_pieces_owned=>200
    },
    :names=>
    {
      :reading_railroad=>
      {
        "mortgage_value"=>"$100"
      },
      :pennsylvania_railroad=>
      {
        "mortgage_value"=>"$200"
      },
      :b_and_o_railroad=>
      {
        "mortgage_value"=>"$400"
      },
      :shortline=>
      {
        "mortgage_value"=>"$800"
      }
    }
  }
}

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!

Resources

  1. What is a Hash in Ruby?
  2. Ruby Documentation on Hashes

ruby-intro-to-hashes-lab's People

Contributors

ahimmelstoss avatar aviflombaum avatar deniznida avatar ehawk823 avatar fislabstest avatar fs-lms-test-bot avatar ga-be avatar ihollander avatar markedwardmurray avatar maxwellbenton avatar msuzoagu avatar octosteve avatar pletcher avatar roseweixel avatar sarogers avatar sophiedebenedetto avatar timothylevi avatar victhevenot avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-intro-to-hashes-lab's Issues

There's an error with the way that the final monopoly hash is shown in the README.

Hello. If you look at the monopoly hash in the README and examine monopoly[:railroads], its values (which themselves are keys) are in this order:

:pieces, :rent_in_dollars, :names.

However, the tests specify that the values of monopoly[:railroads] are supposed to be in this exact order:

:pieces, :names, :rent_in_dollars.

I have attached a screenshot for clarity. Thank you for looking into this.

Sdcrouse

building nested hashes screenshot

break out expect()s

let's work on breaking up some of the expect()s into separate it blocks , especially towards the end. I think they're a bit overwhelming, especially for beginners.

I also really want to figure out a way so that they don't have to repeat their code for each spec :) I don't know how but i think there's a way. let's consult tomorrow and ask for help.

more task specific exposition in readme

you're asking students to make specific hashes with specific keys and values that the spec requires them to make. i think there should be more exposition in the readme about what they're making. go into monopoly, maybe give an example of a hash with that data would look like.

"hash rocket" must to be used when assigning mortgage_value for each railroad to pass tests

Example - This won't pass tests

      names: {
        reading_railroad: {
          "mortgage_value":"$100"
        },
        pennsylvania_railroad: {
          "mortgage_value":"$200"
        },
        b_and_o_railroad: {
          "mortgage_value":"$400"
        },
        shortline: {
          "mortgage_value":"$800"
        }
      },

Example - This will pass the tests

      names: {
        reading_railroad: {
          "mortgage_value"=>"$100"
        },
        pennsylvania_railroad: {
          "mortgage_value"=>"$200"
        },
        b_and_o_railroad: {
          "mortgage_value"=>"$400"
        },
        shortline: {
          "mortgage_value"=>"$800"
        }
      },

intro_to_ruby_hashes_lab_spec.rb

line 148:

`mortgage_value` => '$800'

should be

'mortgage_value'

not a big deal but i was copying and pasting and it caused a moment of issues until i saw the mistake.

rspec let explanation

i just thought that this let block is going to be confusing for them, because it's most likely the first time they're seeing it, and specifically working with it in a spec. i don't think we should go into it too much, but maybe a quick bit about what this is doing.

let(:monopoly) { {} }

coding in spec

re-do so no more coding in spec
re-write readme to intro basic nested hashes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.