Created
September 15, 2014 19:45
-
-
Save tobowers/e006020d9365d37e8491 to your computer and use it in GitHub Desktop.
a quick select implementation
This file contains 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
class Array | |
def select(&block) | |
new_array = [] | |
self.each do |array_element| | |
new_array << array_element if block.call(array_element) | |
end | |
new_array | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment