Skip to content

Instantly share code, notes, and snippets.

@nazgob
Created March 30, 2011 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazgob/894482 to your computer and use it in GitHub Desktop.
Save nazgob/894482 to your computer and use it in GitHub Desktop.
reduce howto
# do this
(5..10).reduce(0) do |sum, value|
sum + value
end
# not this
sum = 0
(5..10).each do |value|
sum += value
end
sum
# m'okey?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment