One case of array assignments

John Colvin john.loughran.colvin at gmail.com
Wed Mar 13 13:59:33 PDT 2013


On Wednesday, 13 March 2013 at 20:46:35 UTC, Timon Gehr wrote:
> On 03/13/2013 09:23 PM, John Colvin wrote:
>> On Wednesday, 13 March 2013 at 20:10:14 UTC, bearophile wrote:
>>>> int[10][3] = [1, 2, 3];
>>>
>>> Currently that second line of code doesn't work.
>>>
>>> Bye,
>>> bearophile
>>
>> It would be really nice if it did.
>
> Then what's the meaning of
>
> int[3][3] x = [1,2,3];
>
> Is it
>
> int[3][3] x = [[1,2,3],[1,2,3],[1,2,3]];
>
> or
>
> int[3][3] x = [[1,1,1],[2,2,2],[3,3,3]];

the former, clearly. It directly follows from

int[3] a = 1;

Every element of the array is initialised to the value given. x 
is an array of arrays and hence each "element-array" is 
initialised to the array on the right hand side.


More information about the Digitalmars-d mailing list