[Apologies for broken threading, it shouldn't happen again]

Matz wrote:
> But the current behavior of enumerator only works right for
> iterators that do not use the values from blocks. e.g. #each.  So,
> enumerators do not work for #inject (and #map).

Could you give an example where it breaks, or what should be avoided? This
might invalidate Feature#707, #708 and #709 :-(

A basic test of inject with Enumerator looks OK to me:

irb(main):001:0> RUBY_VERSION
=> "1.9.1"
irb(main):002:0> (100..110).to_enum.with_index.inject({}) { |h,(v,i)| h[v]=i; h }
=> {100=>0, 101=>1, 102=>2, 103=>3, 104=>4, 105=>5, 106=>6, 107=>7, 108=>8, 109=>9, 110=>10}

Or, are you talking about the automatic creation of an Enumerator when you
call a method like #inject or #map without a block?

I have to admit I'm not sure exactly what that should do anyway :-) I don't
really understand the following:

irb(main):001:0> a = (1..10).select
=> #<Enumerator:0x83be84c>
irb(main):002:0> a.each { |x| x < 5 }
=> [1, 2, 3, 4]

I mean, I can see what it does, but I can't see how it can be used. This
creates an object where 'each' really means 'select', but that only makes
sense when the user passes a block with select-like functionality. So the
caller might as well have done a.select { |x| x < 5 } anyway.

But in any case, #map in this style appears to work:

irb(main):004:0> a = (1..10).map
=> #<Enumerator:0x839db88>
irb(main):005:0> a.each { |x| x * 2 }
=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
irb(main):006:0> a = (1..10).to_enum.map
=> #<Enumerator:0x8387310>
irb(main):007:0> a.each { |x| x * 2 }
=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

Regards,

Brian.