How do I make my class iterable?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 22 13:00:32 PDT 2015


On 06/22/2015 11:48 AM, Assembly wrote:

 > if my opApply() is defiend as the following:
 >
 > int opApply(int delegate(ref int, ref T) del)
 >      {
[...]
 >      }
 >
 > and called like:
 >
 > foreach(int i, MyType p; places) {
 >
 > isn't i the loop counter?

size_t is more natural but yes, that's it.

Ali



More information about the Digitalmars-d-learn mailing list