Ranges, constantly frustrating
Jesse Phillips
Jesse.K.Phillips+D at gmail.com
Thu Feb 13 18:48:51 PST 2014
On Thursday, 13 February 2014 at 14:30:41 UTC, Regan Heath wrote:
>> Don't get me wrong, counting the elements as you iterate over
>> them is useful, but it isn't the index into the range you're
>> likely after.
>
> Nope, not what I am after. If I was, I'd iterate over the
> original range instead or keep a line count manually.
Maybe a better way to phrase this is, while counting may be what
you're implementation needs, it is not immediately obvious what
'i' should be. Someone who desires an index into the original
array will expect 'i' to be that; even though it can be explained
that .take() is not the same range as the original.
Thus it is better to be explicit with the .enumerate function.
More information about the Digitalmars-d-learn
mailing list