Last active
August 29, 2015 13:56
-
-
Save fbernier/8917727 to your computer and use it in GitHub Desktop.
Which do you prefer?
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
# Obviously the second solution is faster or a large collection, but some said the first solution is more readable. | |
# Which would you use? | |
result = [] | |
collection.each do |c| | |
result << some_method(c) | |
end | |
result.reject!(&:nil?) | |
# Versus | |
result = [] | |
collection.each do |c| | |
value = some_method(c) | |
result << value if value | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@fbernier I would say: