Re: Initialize array of objects not work

2016-08-04 Thread Ali Çehreli via Digitalmars-d-learn
On 08/04/2016 09:06 AM, Steven Schveighoffer wrote: 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),

Re: Initialize array of objects not work

2016-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
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

Re: Initialize array of objects not work

2016-08-04 Thread Andre Pany via Digitalmars-d-learn
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

Re: Initialize array of objects not work

2016-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
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

Re: Initialize array of objects not work

2016-08-03 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 3 August 2016 at 18:34:02 UTC, Ali Çehreli wrote: On 08/03/2016 10:58 AM, Andre Pany wrote: > [...] (linear/equals/) > [...] common > [...] quadraticCoefficient(1)~linearCoefficient(2)~equals()~constant(1); [...] Thanks a lot Ali. Kind regards André

Re: Initialize array of objects not work

2016-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 08/03/2016 10:58 AM, Andre Pany wrote: > I try to initialize an array of objects. The methods (linear/equals/) > returns object of different classes, but all implement a common > interface "Element". > > Element[] elements = >

Initialize array of objects not work

2016-08-03 Thread Andre Pany via Digitalmars-d-learn
Hi, I try to initialize an array of objects. The methods (linear/equals/) returns object of different classes, but all implement a common interface "Element". Element[] elements = quadraticCoefficient(1)~linearCoefficient(2)~equals()~constant(1); I tried different casts and different