InstanceOf

Artur Skawina art.08.09 at gmail.com
Sun Jun 23 04:12:37 PDT 2013


On 06/23/13 13:04, Lemonfiend wrote:
>     void writeAll()
>     {
>         foreach(elem; array)
>             elem.write();
>     }
> 
>     void writeB()
>     {
>         // Only call .write on B's
>         // How do I get the B's from the array of I's?
>     }

    void writeB()
    {
        foreach(elem; array)
           if (auto b = cast(B)elem)
               b.write();
    }

artur


More information about the Digitalmars-d-learn mailing list