Initialize array of objects not work
Andre Pany via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 4 08:19:19 PDT 2016
On Thursday, 4 August 2016 at 13:48:46 UTC, Steven Schveighoffer
wrote:
> On 8/3/16 2:34 PM, Ali Çehreli wrote:
>
>> void main() {
>> Element[] elements = cast(Element[])[
>> quadraticCoefficient(1),
>> linearCoefficient(2), equals(), constant(1) ];
>
> is the cast necessary? I assumed the compiler would infer the
> common base type...
>
> -Steve
I just tested it. The compiler cannot infer interface Element.
By changing the type from interface to class the compiler
is happy without the cast.
Does it worth to open an enhancement request for this specific
issue?
Kind regards
André
More information about the Digitalmars-d-learn
mailing list