foreach statement: Are there no Iterators in D?

rsw0x via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 8 09:07:18 PST 2015


On Sunday, 8 November 2015 at 11:57:16 UTC, J.Frank wrote:
> On Sunday, 8 November 2015 at 11:47:41 UTC, Rikki Cattermole 
> wrote:
>> opApply if you want 0 .. N iterations during for a foreach 
>> statement and having it reset each time.
>
> No, that won't help. I want to be able to iterate over a data 
> set of infinite size.
>
>> Otherwise you want ranges :)
>>
>> An input range is more or less an iterator as you would think 
>> of it.
>> You only need popFront, front and empty.
>
> Ah yes, that's what I missed. Looks good. Thank you. :)

FWIW since you mentioned Java, if you're accustomed to Java 8 
streams they're very similar to D's ranges.


More information about the Digitalmars-d-learn mailing list