foreach for self-defined data-structure?

BCS BCS at pathlink.com
Wed Feb 21 11:29:01 PST 2007


Michiel wrote:
> I'm slowly working on a complete Set class. It would be good if I could
> do this:
> 
> auto x = Set!(int);
> foreach (element ; x) { ... }
> 
> Is there a way for me to define foreach for my own class? If not, maybe
> there should be.
> 

look for opApply here

http://www.digitalmars.com/d/statement.html#ForeachStatement



More information about the Digitalmars-d mailing list