You might find this interesting too...

string yield(string what) { return `if(auto result = dg(`~what~`)) return result;`; }

    int opApply(int delegate(ref uint) dg) {
        for (int i = 0; i < array.length; i++)
                mixin(yield("array[i]"));

        return 0;
    }


The little mixin does the boilerplate making opApply
a bit more succinct, without anything really fancy.

Reply via email to