Enumerators can only "move" in one direction - forward. #end would be
useless for many (for ex. (1..Float::INFINITY).each - this one never
ends), providing #prev would be equivalent to remembering all of
values yielded so far (unpractical, we don't have infinite memory).

-- Matma Rex



2012/3/12 Ralph Shnelvar <ralphs / dos32.com>:
> I see that enumerators have the methods rewind and next.
>
> Are there equivalent methods "end" and "prev"?
>
> I see reverse_each ... but what if I do have a large enumerable object and don't want the intermediate array created?
>
>
>
> The documentation ( http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-reverse_each ) for reverse each says:
>
> - - -
>
> reverse_each(*args) {|item| block } ? enum click to toggle source
> reverse_each(*args) ? an_enumerator
>
> Builds a temporary array and traverses that array in reverse order.
>
> If no block is given, an enumerator is returned instead.
>
> - - -
>
>