Initialize array of objects not work
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 4 09:06:01 PDT 2016
On 8/4/16 11:19 AM, Andre Pany wrote:
> 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?
Ah, it's an interface. I thought it was a base class.
This is expected, no need to open a request.
-Steve
More information about the Digitalmars-d-learn
mailing list