Peñá, Botp wrote:
>
> [...] wouldn't that make creating additional methods like
>
> each
> each_with_index
> map
> map_with_index
> collect
> collect_with_index
> ..
>
> ?
>
> it's with_index es all over..
>

It is.  None are required; not even each_with_index.

>
> Also, if we create a with_index method, wouldn't that be invoking another
> method just for the index, like
>
> each_with_index.map
> or
> map.with_index
>
> Wouldn't my algorithm slow down? Does not the chain begs for a single method
> -which brings us back to the original question...?
>

Yes.  I'm taking sedatives while it's seriously being considered that
an Array should become an Enumerator in order to use its #with_index method
on an intermediate #map object to produce ... an Array ... instead of the
regular #map method with an optional index.

I would have posted a link to the ruby-core thread, but it was my
first post to a mailing list and my MAIL settings were different
from my NEWS settings, so it's messed up (quoted-printable MIME).

Here's a text version (minor EDITs).  I'm sure it'll be relevant to you.

   http://www.d10.karoo.net/ruby/xv/ruby-core-1495.txt

You'll see examples using bang! methods.

(( I'd be fascinated to see map!.with_index or map.with_index!
   produce anything intelligible using require 'enumerator'. ))


>
> kind regards -botp
>

daz