Thomas Sawyer wrote in post #1011313:
> On Jul 17, 10:36pm, John Feminella <jo... / bitsbuilder.com> wrote:
>> How about #zip_and_map? Notice that:
>>
>> > a.zip_with(b) { |c, d| ... }
>>
>> is the same as the result of
>>
>> > a.zip(b).map { |c, d| ... }
>
> Ah, right. `#zip_map` would makes sense then. But per your last post,
> I think I may override #zip itself.

Not sure whether I find this a good idea.  Reason: #map has overhead of
creating a new Array with the same length as the input.  That should not
be the default behavior IMHO.  A clean separation would be

[].zip([]) => Enumerator
[].zip([]) {|a,b| ...} => nil (as today) or self (i.e. leftmost Array)

Then we can efficiently have [].zip([]).map {|a,b| ...}

But it would break old code. :-(

So, today for efficient zip + map we would have to do

[].enum_for(:zip, []).map {|a,b| ...}

Kind regards

robert

-- 
Posted via http://www.ruby-forum.com/.