Skip to content

Instantly share code, notes, and snippets.

@kirel
Created September 19, 2009 08:25
Show Gist options
  • Select an option

  • Save kirel/189441 to your computer and use it in GitHub Desktop.

Select an option

Save kirel/189441 to your computer and use it in GitHub Desktop.
module Enumerable
def sum(*args, &block)
if block_given?
map &block
else
self
end.inject(*args) { |sum, x| sum + x }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment