Created
September 29, 2008 02:18
-
-
Save aviflombaum/13543 to your computer and use it in GitHub Desktop.
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
# Will yield sets of size, useful when you have to iterate over large sets | |
# if you have an array of 50k elements, running .each is slow. | |
def in_blocks_of(s) | |
(1..(self.size/s)).each{|i| yield self[((s)*(i-1))...((s)*i)]} and yield self[((self.size/s)*s)...self.size] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment