From: "David A. Black" Date: 2005-07-12T02:55:27+09:00 Subject: Re: accessing index inside map --927295978-886923594-1121104497=:17833 Content-Type: MULTIPART/MIXED; BOUNDARY="927295978-886923594-1121104497=:17833" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --927295978-886923594-1121104497=:17833 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Mon, 11 Jul 2005, daz wrote: > > Pe=F1a, 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 anothe= r >> 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 me= thod >> -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 meth= od > on an intermediate #map object to produce ... an Array ... instead of the > regular #map method with an optional index. I don't think that's a correct description of what's being considered. It's more like: have certain Enumerable instance methods, in the absence of a block, return an enumerator rather than fail. No array is "becoming" an Enumerator; rather, a method of Array is returning an Enumerator. Mind you, my reaction even after looking at it for a long time is that it's too "magic" and eliptical. But I don't think it's tangled or illogical. It's just a big leap, because it means Enumerators would have core rather than stdlib status, so to speak. David --=20 David A. Black dblack@wobblini.net --927295978-886923594-1121104497=:17833-- --927295978-886923594-1121104497=:17833--