Git Product home page Git Product logo

enumerable-methods's Introduction

Enumerable Methods

This is a copy of Ruby Enumerable module with some if its methods.

Getting Started

One can either download the enumerable.rb and include it to its project or just copy the code from the enumerable.rb file into ones project.

Example for my_each:

[12, 2, 4, 56, 34].my_each { |int| print (int * 2).to_s + " " } => 24 4 8 112 68

Example for my_each_with_index:

hash = {}
%w[cat dog wombat].my_each_with_index { |item, index| hash[item] = index } => {"cat"=>0, "dog"=>1, "wombat"=>2}

Example for my_select:

(1..10).my_select { |i| i % 3 == 0 } => [3, 6, 9]

Example for my_all?:

[1, 2i, 3.14].my_all?(Numeric) => true

Example for my_any?:

%w[ant bear cat].my_any?(/d/) => false

Example for my_none?:

%w{ant bear cat}.my_none? { |word| word.length == 5 } => true

Example for my_count:

[1, 2, 4, 2].my_count{ |x| x % 2 == 0 } => 3

Example for my_map:

[3, 23, 45, 34].my_map { |i| i * i } => [9, 529, 2025, 1156]

Example for my_inject:

(5..10).my_inject(1) { |product, n| product * n } => 151200

Prerequisites

Ruby needs to be installed before one is able to run Ruby code in its computer.

Built With

  • Ruby - Programming language used
  • VS Code - The code editor used

Authors

  • Jaak Kivinukk - Initial work - Jaakal

License

This project is licensed under the MIT License - see the LICENSE file for details

enumerable-methods's People

Contributors

jaakal avatar clintonenyinna avatar

Watchers

James Cloos 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.