Skip to content

Instantly share code, notes, and snippets.

@owainlewis

owainlewis/chunks.rb

Created Apr 28, 2012
Embed
What would you like to do?
Grouping sequence by n in Ruby
def group_sequence_by n, sequence
Array.new.tap do |result|
sequence.each_slice(n) { |item| result << item }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment