Created
June 18, 2012 22:17
-
-
Save jessieay/2951088 to your computer and use it in GitHub Desktop.
Redefinition of inject
This file contains hidden or 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
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