Implementing Iterator to support foreach
tcak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 7 22:59:17 PDT 2015
I am planning to implement "Iterator" class. But looking at
"foreach" statement, it takes a range only.
So is there any way other than returning an array from a function
that is to be passed foreach statement? So I could write like
that:
Iterator iter = new MyList();
foreach(item; iter){
}
Otherwise I will need to write like that:
foreach(item; iter.getArrayOfAvailableItems()){
}
More information about the Digitalmars-d-learn
mailing list