enumerated iteration to struct
Fra Mecca
me at francescomecca.eu
Wed Feb 7 01:21:16 UTC 2018
On Wednesday, 7 February 2018 at 01:10:34 UTC, Fra Mecca wrote:
> I don't know if this post belongs to the learn section, but
> I'll try anyway.
>
> I am using the std.path.pathSplitter function that returns a
> PathSplitter function exposing ranges primitive.
>
> I have some question that could be generalized to other structs
> that expose range primitives.
>
> 1. Why can't I write foreach(i, el;
> pathSplitter("foor/bar").enumerate) ?
> 2. Supposing I want to fix this problem, what do I add to the
> struct? opApply?
There was a stupid stupid error on my part because I wasn't
import the range module.
> 3. Why doesn't ranges infer the iteration method at compile
> time so that I don't need to write enumerate?
This question is still valid.
I think it would be saner to write
foreach(idx, el; paths)
instead of
foreach(idx, el; paths.enumerate)
More information about the Digitalmars-d-learn
mailing list