Enumerator.new(size = nil) { |yielder| ... }Enumerator.new(obj, method = :each, *args)
Class Public methods
Creates a new Enumerator object, which can be
used as an Enumerable.
In the first form, iteration is defined by the given block, in which a
âyielderâ object, given as block parameter, can be used to yield a value by
calling the yield method (aliased as +<<+):
fib = Enumerator.new do |y|
a = b = 1
loop do
y << a
a, b = b, a + b
end
end
p fib.take(10