From: Christopher Dicely Date: 2010-09-04T00:12:48+09:00 Subject: Re: Enumerator#each return value is surprising On Thu, Sep 2, 2010 at 7:57 PM, Ryan Davis wrote: > > That said, I think the result is as it should be, as enumerators should be (in my mind at least) acting as stand-ins for > the real thing, they should be substitutable with the real thing and wind up with the same result: I suppose when the enumerator is created with the default options, I can sort of see that (or at least, see it as unlikely to be harmful.) When its created with enum_for with an argument other than :each, though, it seems to me like you end up with more possibility for unexpected results. e.g., array = ["a","b","c"] enum = array.enum_for(:each_with_index) enum.each {} # => ["a","b","c"] enum.to_a.each {} # => [["a", 0], ["b", 1], ["c", 2]] That is, even ignoring the implementation class, the sequence returned by Enumerator#each isn't always the same sequence that the Enumerator represents. This isn't like any other Enumerable in core Ruby.