> 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"]]
> [1, ["4", "5", "6"]]
> [2, ["7", nil, nil]]
> => nil
> irb(main):008:0>
Sure, actually both methods are just syntactic sugar over the grouping methods:
with_index_in_groups_of = in_groups_of + each_with_index
with_index_in_groups = in_groups + each_with_index
J.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.