Giter Club home page Giter Club logo

enum_methods's Introduction

Enumerable

Enumerable is a collection of iteration method, a Ruby module and a great part of what makes ruby a great programming language. In this project, we try to customize some of the Ruby enumerable functions.

Setup Instruction

  • Clone this Repo
  • Navigate to project Directory
  • Now, to test each function go to the end of the page and do the following.
  • For my_each
[1, 2, 3, 5].my_each { |x| p x }
  • Output
=> 1
=> 2
=> 3
=> 5
  • For my_each_with_index
[1, 2, 3, 5].my_each_with_index { |x, y| puts "#{x} at #{y}" }
  • Output
=> 1 at 0
=> 2 at 1
=> 3 at 2
=> 5 at 3
  • For my_select
[1, 2, 3, 4].my_select { |x| x % 2 == 0}
  • Output
=> [2, 4]
  • For my_all
['alpha', 'apple', 'allen key'].my_all?{ |x| x[0] == 'a' }
  • Output
=> true
  • For my_any
['alpha', 'apple', 'allen key'].my_any?{ |x| x[-1] == 'y' }
  • Output
=> true
  • For my_none
['Alpha', 'Apple', 'Allen key'].my_none?{ |x| x[0] == 'z' }
  • Output
=> true
  • For my_count
arr = [1, 2, 3, 4]
arr.my_count { |i| i%2==0}
  • Output
=> 2
  • For my_map
[1,2,3,4,4,7,7,7,9].my_map { |i| i*4 }
  • Output
=> [4, 8, 12, 16, 16, 28, 28, 28, 36]
  • For my_inject
[1,2,3,4,4,7,7,7,9].my_inject(0){|running_total, item| running_total + item }
  • Output
=> 44

Live Demo

Live Demo Link

Built With

  • Ruby

Authors

๐Ÿ‘ค Rukundo Eric

๐Ÿ‘ค Sinan Sevgi

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!

Show your support

Give a โญ๏ธ if you like this project!

Acknowledgments

  • We would like to thank our code reviewer and anyone else who participated in making this done.

๐Ÿ“ License

This project is MIT licensed.

enum_methods's People

Contributors

rukundoeric avatar sinansevgi avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

rukundoeric

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.