[Issue 5550] std.range.enumerate()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 16 08:13:31 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=5550



--- Comment #10 from bearophile_hugs at eml.cc 2014-01-16 08:13:27 PST ---
(In reply to comment #9)

> Posted a pull request for a library implementation. [...]
> 
> https://github.com/D-Programming-Language/phobos/pull/1866

Seems nice.

A comment from the pull request:

> This could also be implemented in the language (though
> potentially ambiguous with automatic foreach unpacking),
> but here's a library solution for review.

In some cases I like language-level solutions, but in this case I think the
library solution is good enough and safer.

Regarding your implementation, I suggest to add an optional "start" argument,
as in Python enumerate():

auto data = [10, 20];
foreach (i; x; data.enumerate(3))
    write(i, " ");

==>

3 4

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list