I am trying to get the next n
number of elements using a Ruby enumerator, with this:
a = [1, 2, 3, 4, 5, 6]
enum = a.each
enum.next(2) # expecting [1, 2]
enum.next(2) # expecting [3, 4]
But #next
does not support that. Is there another way that I can do that?
Or shall I do?
What is the correct Ruby way to do that?