Skip to content

Instantly share code, notes, and snippets.

@seejohnrun
Created February 2, 2011 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seejohnrun/808552 to your computer and use it in GitHub Desktop.
Save seejohnrun/808552 to your computer and use it in GitHub Desktop.
# split into groups of maximum size BATCH_SIZE
groups = []; grp = nil
items.each_with_index do |item, idx|
groups << (grp = []) if idx % BATCH_SIZE == 0
grp << item
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment