Created
September 12, 2019 04:12
-
-
Save inopinatus/da385f60edf127345fe1adc3d695fa1e to your computer and use it in GitHub Desktop.
Array#fold
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
class Array | |
class << self | |
def fold((head, *tail), &block) | |
block::(head, *tail) | |
end | |
end | |
def fold(&block) | |
self.class.fold(self, &block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: