> Can't you just use the enumerators that are built in to Array itself?
> For example:
>
> irb(main):006:0> x = %w(1 2 3 4 5 6 7)
> => ["1", "2", "3", "4", "5", "6", "7"]
> irb(main):007:0> x.each_slice(3).each_with_index { |(a, b, c), i|
> p [i, [a, b, c]] }
> [0, ["1", "2", "3"]]
On Sat, May 14, 2011 at 06:44:44AM -0700, Juanjo Bazan wrote:
> I've found useful to have a port of the Array#each_with_index
> functionality to the already existent grouping methods (in_groups_of,
> in_groups). That way we add the ability to iterate over an array in
> groups and having an index fo
I've found useful to have a port of the Array#each_with_index
functionality to the already existent grouping methods (in_groups_of,
in_groups). That way we add the ability to iterate over an array in
groups and having an index for each group.
In case you think it's interesting I've created a coupl