foreach - How to make a object (class) foreachable in D? -


How can I make the class eligible for a foreach statement?

In the class, an associative array (eg string [string]), the above statement, uses this array as a source.

So this is what I want:

  auto obj = new obj (); Foreach (key, value; obj) {...}  

Do I have to implement the interface for some time like this?

Edit:

Solution:

  Public Ent Operation (Int Rep (referee string, Ref type) DG) {int result = 0; Foreign currency (referee, ref price; data) {result = dg (key, value); If (results! = 0) {break; }} Return result; }  

This is done for the Public Ent Operate (Int Rep (DG)).

:

  class Foo {uint array [2]; Int opeple (int representative (referee UIP) dg) {int result = 0; For (int i = 0; i & lt; array.label; i ++) {result = dg (array [i]); Break the (result); } Return results; }}  

:

Structure and class objects can be done with a range of diagrams, which means [a set of properties] is defined Should:


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -