Giter Site home page Giter Site logo

keys-of-hash-dumbo-web-career-010719's Introduction

Keys Of Hash

Objectives

  1. Practice manipulating hashes
  2. Practice using the splat operator
  3. Understand what monkey patching is

Instructions

Fork and clone this lab. Run learn to see what the tests require of you. In this lab you'll be modifying Ruby's Hash class. This is called monkey patching.

What is Monkey Patching

Monkey patching is the practice of re-opening and modifying pre-existing classes. So, Ruby already has a Hash class, the instances of which you've been working with in the past two units. If we create a file that reads:

class Hash

  #some stuff
  
end

Ruby will understand that the Hash class already exists and that you are modifying/adding to it.

Danger!

Monkey patching is generally avoided. You don't want to mess with the implementation of the objects and methods native to Ruby. It could get messy, fast. What if you monkey patch the Hash class and accidentally overwrite or interfere with some functionality that you need to utilize? What if you monkey patch the hash class and then your bff/co-worker/boss/someone you have never even met before in our wonderful open-source community tried to build on your code and gets confused and thwarted by your monkey patches?

Back to the instructions...

You'll be coding your solution in lib/keys_of_hash.rb. You'll fill out the content of the keys_of_hash method which is an instance method that we are adding to the Hash class. This means that any instance of the Hash class, i.e. any hash, can now have .keys_of_hash called on it.

This method should take an undefined number of arguments, using the splat operator, and return an array with every key from the hash whose value matches the value(s) given as an argument.

Resources

View Keys Of Hash on Learn.co and start learning to code for free.

keys-of-hash-dumbo-web-career-010719's People

Contributors

annjohn avatar deniznida avatar drewprice avatar fislabstest avatar fs-lms-test-bot avatar kthffmn avatar morgvanny avatar roseweixel avatar sarogers avatar sophiedebenedetto 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  avatar  avatar  avatar  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.