Is there a brief way to iterate an array of objects, and process only objects of certain type (in either two ways, with/without inheritance)?

        foreach(p; obj.children){ // "KObj[] children"
                DPFile dfile = cast(DPFile)p;
                if(!dfile)continue;
                ...
        }

I saw the std.algorithm.filter template helper could be used, but it's a bit complex:

foreach(unit; file.children.filter!(a => cast(KUnit)a)){
...
}


Thanks

Reply via email to