Coder Social home page Coder Social logo

assansav / programming-univbasics-4-nested-hashes-lab-online-web-prework Goto Github PK

View Code? Open in Web Editor NEW

This project forked from learn-co-students/programming-univbasics-4-nested-hashes-lab-online-web-prework

0.0 1.0 0.0 27 KB

License: Other

Ruby 100.00%

programming-univbasics-4-nested-hashes-lab-online-web-prework's Introduction

Simple Nesting Lab

Learning Goals

  • Access data from a nested hash
  • Add data to and change data within a nested hash

Introduction

Now that we've seen some examples of nested hashes, the next step is to get more comfortable with using them. In this lab, we're going to practice accessing and updating data within a nested hash.

Instructions

You'll be filling out the content of a series of methods that we've defined for you. All of the methods expect you to operate on the programmer_hash object, which we've already defined and included in the body of each method. Use the test suite to guide you. Each test is designed to tell you how to pass it.

Keep in mind that you are expected to get these tests to pass by adding or changing information in the hash programmatically. In other words, if you're asked to, for example, change the value of a certain hash key, don't just re-write the hash with the new value! Use the methods we've learned and practiced in previous lessons.

To quickly review, here is an example of adding data to a hash programmatically:

# good example

my_hash = {first: "I'm first!", second: "I'm second!"}
my_hash[:third] = "I'm third!"

puts my_hash
# > {first: "I'm first!", second: "I'm second!", third: "I'm third!"}

Changing a hash by simply re-defining it is not the goal of this lab:

# bad example

my_hash = {first: "I'm first!", second: "I'm second!"}
my_hash = {first: "I'm first!", second: "I'm second!", third: "I'm third!"}

Hint: In some of these methods, you will need to alter programmer_hash, then make sure to return the entire hash, not just the altered value.

Conclusion

Adding and updating data in a nested hash is just like adding and updating a normal hash. If we know the structure, it is just a matter of using the right combination of keys.

As we see examples of more complex data structures, we'll start to encounter situations where we aren't 100% of the structure of a hash. This is one reason why getting familiar with programmatically changing hash data is critical - we won't always be able to see the hash we're changing. Instead, we'll have to write logic that and correctly handles accessing and updating hash data in a more abstracted way.

programming-univbasics-4-nested-hashes-lab-online-web-prework's People

Contributors

maxwellbenton avatar kthffmn avatar sophiedebenedetto avatar victhevenot avatar markedwardmurray avatar deniznida avatar gj avatar corasan avatar kjleitz avatar fs-lms-test-bot avatar sarogers avatar octosteve avatar fislabstest avatar assansav avatar aviflombaum avatar changamanda avatar ga-be avatar benjagross avatar

Watchers

James Cloos avatar

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.