On Sat, Aug 31, 2013 at 12:52 AM, marcandre (Marc-Andre Lafortune) <
ruby-core / marc-andre.ca> wrote:

> Defining an Enumerator that require a state is currently troublesome. For
> example, it is not really possible to define an equivalent of Lazy#drop in
> Ruby without making an assumption on the implementation.
>

Can't you just use the closure?


>   class Enumerator::Lazy < Enumerator
>     def drop(n)
>       n = n.to_i
>       Lazy.new(self) do |yielder, *values|
>         if n > 0
>           n -= 1
>         else
>           yielder.yield(*values)
>         end
>       end
>     end
>   end
>