Skip to content

Instantly share code, notes, and snippets.

@jessieay
Created June 18, 2012 22:17
Show Gist options
  • Save jessieay/2951088 to your computer and use it in GitHub Desktop.
Save jessieay/2951088 to your computer and use it in GitHub Desktop.
Redefinition of inject
class Array
def new_inject
result = 0
(1..self.length).each do |i|
result = yield(result, self[i-1])
end
result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment