Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve all Enumerables challenges #107

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sheshtawy
Copy link

Copy link
Member

@jaybobo jaybobo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. see comments.

challenge.rb Outdated
end

def no_dogs_allowed(input)
input = input.dup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

challenge.rb Outdated
end

def count_the_animals(input)
input.length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length isn't actually an enumerable but there's good reasons for familiarizing yourself with it and it's counterparts (eg. .size, .count) use cases.

see this article: http://batsov.com/articles/2014/02/17/the-elements-of-style-in-ruby-number-13-length-vs-size-vs-count/

https://ruby-doc.org/core-2.5.1/Enumerable.html#method-i-count

end

def fetch_the_first_two(input)
input[0, 2]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

challenge.rb Outdated
end

def fetch_CD_animals(input)
input.find_all { |animal| animal.start_with?("c", "d")}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

challenge.rb Outdated
end

def fetch_the_dog(input)
input.find_all { |animal| animal == "dog" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants