How to iterate using foreach on a class?

simendsjo simendsjo at gmail.com
Fri Nov 1 04:35:02 PDT 2013


On Friday, 1 November 2013 at 11:30:12 UTC, Gary Willoughby wrote:
> I have a class which contains an array as a core collection of 
> data. I want to pass an instance of this class to a foreach 
> loop and iterate through the enclosed array. How do i do this? 
> I've asked this before and got an answer but i can't find 
> anything now.

alias this on the underlying array, or implement opApply: 
http://dlang.org/statement.html


More information about the Digitalmars-d-learn mailing list