digitalmars.D.learn - Array initialisation vs assignment
- ed (21/21) Mar 14 2014 Hi All,
- bearophile (5/11) Mar 14 2014 That looks like a compiler bug. You are supposed to use a cast to
- ed (2/13) Mar 14 2014 OK, thanks I'll file it.
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
Mar 14 2014
ed:void main() { int[] a = [1,2,3,4]; int[2][2] b = a; // fine, does an array copy }Is it a bug or by design?That looks like a compiler bug. You are supposed to use a cast to do an assignment like that. Bye, bearophile
Mar 14 2014
On Friday, 14 March 2014 at 23:10:57 UTC, bearophile wrote:ed:OK, thanks I'll file it.void main() { int[] a = [1,2,3,4]; int[2][2] b = a; // fine, does an array copy }Is it a bug or by design?That looks like a compiler bug. You are supposed to use a cast to do an assignment like that. Bye, bearophile
Mar 14 2014








"ed" <growlercab gmail.com>