Array initialisation vs assignment

ed growlercab at gmail.com
Fri Mar 14 16:01:29 PDT 2014


Hi All,

I would expect both blocks of code below to behave in the same 
manner but they don't.

---
void main()
{
     int[] a = [1,2,3,4];
     int[2][2] b = a; // fine, does an array copy
}
---
void main()
{
     int[] a=[1,2,3,4];
     int[2][2] b;
     b = a; // compile time error
}
---

Is it a bug or by design?
(and if by design why?)

Cheers,
ed


More information about the Digitalmars-d-learn mailing list