Giter Site home page Giter Site logo

my-collect-v-000's Introduction

My #collect

Objectives

  1. Build a method that yields members of a collection to a block.
  2. Control the return value of a method that uses yield such that it returns a new collection.

Instructions

You'll be writing your code in lib/my_collect.rb.

Let's say we are writing an app to help teachers manage their students. Our teacher has a list of students:

["Tim Jones", "Tom Smith", "Jim Campagno"]

The list includes the first and last name of each student, but our teacher needs to collect a list of just their first names.

You are writing a method that behaves just like the real #collect method. It should take in an argument of a collection, iterate over that collection using a while loop, and execute the code in the block you call it with for each element in the collection (use the yield keyword). It should return the modified collection.

So, if our teacher uses #my_collect to collect the first name of his students, it should work like this:

array = ["Tim Jones", "Tom Smith", "Jim Campagno"]
my_collect(array) do |name|
  name.split(" ").first
end

Should return:

["Tim", "Tom", "Jim"]

Make sure to run bundle install before running your tests.

my-collect-v-000's People

Contributors

sophiedebenedetto avatar deniznida avatar dom-mc avatar annjohn avatar fs-lms-test-bot avatar dakotalmartinez avatar irmiller22 avatar sarogers avatar fislabstest avatar ahimmelstoss avatar joshuabamboo avatar markedwardmurray 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.