Giter VIP home page Giter VIP logo

enumerable-methods-071320's Introduction

Zoo Organization

In this project, you will be practicing the various enumerable methods available in Ruby. Please read the whole README before writing anything.

Introduction

Today, you are in charge of maintaining some of the zoos in NYC and the animals in each of them. Your goal is to write in the code as they are listed in the deliverables. Do your best to follow Ruby best practices. For example, use higher-level array methods such as map, select, and find when appropriate in place of each.

Notes

Here are some notes for you to keep in mind when building out this lab: When the lab mentions

Consider which higher-level enumerable method(s) you'd use here.

You should consider using the methods that aren't each.

Array

  • each:

    • Block parameter: Single element of the array
    • Block: You can do whatever in the block
    • Returns: The array you're iterating over
  • map:

    • Block parameter: Single element of the array
    • Block: Last line needs to be how you want to transform the element
    • Returns: A new array filled with elements based on the last line of your block
    • Note:
      • Will always return an array of the same length
  • select:

    • Block parameter: Single element of the array
    • Block: Last line needs to be a condition
    • Returns: A new array filled with elements satisfying the condition on the last line of your block
    • Note:
      • Will always return a sub-array of the original array
      • If nothing satisfies the condition, will return []
  • find:

    • Block parameter: Single element of the array
    • Block: Last line needs to be a condition
    • Returns: The first element of the array satisfying the condition on the last line of your block
    • Note:
      • Will return one element of the original array
      • If nothing satisfies the condition, will return nil

Hash

  • each:

    • Block parameter: First is the key, second is the value
    • Block: You can do whatever in the block
    • Returns: The hash you're iterating over
  • map:

    • Block parameter: First is the key, second is the value
    • Block: Last line needs to be how you want to transform the element
    • Returns: A new array filled with elements based on the last line of your block
    • Note:
      • Will always return an array of the same length as the hash's key-value pair
  • select:

    • Block parameter: First is the key, second is the value
    • Block: Last line needs to be a condition
    • Returns: A new hash filled with key-value pairs satisfying the condition on the last line of your block
    • Note:
      • Will always return a sub-hash of the original
      • If nothing satisfies the condition, will return {}
  • find:

    • Block parameter: First is the key, second is the value
    • Block: Last line needs to be a condition
    • Returns: The array of length two - the first element will be the key and the second element will be the value, satisfying the condition on the last line of your block
    • Note:
      • Will return an array of length 2
      • If nothing satisfies the condition, will return nil

enumerable-methods-071320's People

Contributors

hyeokjungkim 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.