Created
September 30, 2013 22:11
-
-
Save ahimmelstoss/6771065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fruit_array = ["apple", "pear", "orange", "banana", "apple", "peach", "Apple"] | |
def apple_picker(array) | |
array.select { |fruit| fruit.downcase == "apple" } | |
end | |
apple_picker(fruit_array) | |
#Implement it with collect and then implement it with select. | |
#Write a sentence about how select differs from collect. | |
#collect not possible as it returns an array of equal size | |
#Select returns a new array of all of the elements that return true given the block iterated over the elements. | |
#Collect returns a new array of equal value of elements with the block iterated over the elements. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment