digitalmars.D.learn - Having some issues using Generator's yield with an interface
- Ben (15/15) Nov 02 2015 When I create a generator using an interface (or abstract class)
When I create a generator using an interface (or abstract class) I must cast the concrete instance to the interface. Why does the Generator not know that B is a implementation of the interface of A? /// Test Code interface A {} class B : A{} // Fails auto testGen1 = new Generator!A({ yield (new B()); }); // Succeeds auto testGen2 = new Generator!A({ yield ( cast(A) new B()); });
Nov 02 2015