method
each_slice
v1_8_6_287 -
Show latest stable
- Class:
Enumerable
each_slice(p1)public
Iterates the given block for each slice of <n> elements.
e.g.:
(1..10).each_slice(3) {|a| p a}
# outputs below
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
[10]
1Note
Needs requiring 'enumerator' to work
This method needs that you
require 'enumerator'
for this method to be available.