foreach range with index

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 14 15:53:13 PDT 2017


On 06/14/2017 03:48 PM, bachmeier wrote:
> On Wednesday, 14 June 2017 at 22:02:30 UTC, Ali Çehreli wrote:
>
>> Then, perhaps we're arguing in favor of
>>
>> * writing .enumerate even for slices (implying that automatic indexing
>> for them has been a historical artifact and code that wants to be
>> portable should always write .enumerate)
>>
>> * making sure that enumerate() on arrays don't bring extra cost
>>
>> Ali
>
> I like this proposal.
>
> Is there a reason you don't introduce .enumerate in the section of your
> book "The counter is automatic only for arrays"?

No reason other than ranges appear later in the book. But I took a note; 
I will add your suggestion soon.

Otherwise, .enumerate is mentioned here:

 
http://ddili.org/ders/d.en/foreach_opapply.html#ix_foreach_opapply.enumerate,%20std.range

Ali



More information about the Digitalmars-d mailing list