Ruby Language Rewinding


Example

Use rewind to restart the enumerator.

ℕ = Enumerator.new do |yielder|
  x = 0
  loop do
    yielder << x
    x += 1
  end
end

ℕ.next
# => 0

ℕ.next
# => 1

ℕ.next
# => 2

ℕ.rewind

ℕ.next
# => 0