Created
January 12, 2013 04:27
-
-
Save kmandreza/4516092 to your computer and use it in GitHub Desktop.
Refactor a method
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
def method_4(array) | |
results = [] | |
array.each do |num| | |
if num % 2 == 0 | |
results << num | |
end | |
end | |
return results | |
end | |
#Refactored | |
def method_4(array) | |
array.select {|y| y%2 == 0} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment