To solve the problem with the 1-variable and 2-variable versions of foreach I tried opApply and found that the compiler prefers it over opSlice and opIndex() (the latter without argument).

My code:

```d
        int opApply(int delegate(Variant) foreachblock) const {
                int result = 0;
                foreach(val; dct) {
                        result = foreachblock(val);
                        if (result)
                                break;
                        }
                return result;
        }
        int opApply(int delegate(Variant, Variant) foreachblock) const {
                int result = 0;
                foreach(key, val; dct) {
                        result = foreachblock(key, val);
                        if (result)
                                break;
                }
                return result;
        }
```
So I'm fine with this now.


Reply via email to