What prevents you from doing:
```D
import std.sumtype;

class Foo {}
class Bar {}

alias Item = SumType!(Foo, Bar);

void main()
{
Item[] items = [Item(new Foo()), Item(new Bar()), Item(new Foo()), Item(new Bar())];
    foreach (item; items)
    {
        item.match!(
            (Foo v) { /* do something with foo */ },
            (_) {}
        );
    }
}
```
?
It's more effective by the way - you check the type once only.

Reply via email to