Is it possible to store different subclasses in one array?

Manfred Nowak svv1999 at hotmail.com
Tue Apr 14 22:02:46 UTC 2020


On Monday, 13 April 2020 at 05:54:52 UTC, evilrat wrote:
>     if (auto weapon = cast(Weapon) gi)
>         weapon.Attack();

Does the parlor (currently illegal in Dlang)

       if (Weapon w := gi)
           w.Attack();

look nicer or even (currently legal):

       if (Weapon w ._= gi)
           w.Attack();


More information about the Digitalmars-d-learn mailing list