Created
October 31, 2011 18:00
-
-
Save sw17ch/1328199 to your computer and use it in GitHub Desktop.
Some times I love monkey patching.
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 | |
def subdivide(len) | |
return self if len <= 0 || len >= self.size | |
from = 0 | |
result = [] | |
while from < self.size | |
result << self.slice(from, len) | |
from += len | |
end | |
result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment