For better readability, define it in a library. And if it's
defined in a library, well, you might want to write the
implementation in a readable way... :}
gegroet,
Erik V. - http://www.erikveen.dds.nl/
----------------------------------------------------------------
module Enumerable
def group_by_size(size)
res = []
each_with_index do |o, n|
res << [] if n%size == 0
res[-1] << o
end
res
end
end
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b = a.group_by_size(3)
p a
p b
----------------------------------------------------------------