On Sun, Sep 9, 2012 at 2:48 PM, Samuele Carcagno <[email protected]> wrote:
> thanks a lot! both solutions work, to initialize the arrays of int I'm
> doing:
>
> int[][][string] foo;
> foo["key"] = new int[][](6,6);
> foo["key"][0][0] = 5;
>
> it seems to work.
Great!
Keep in mind all these structures (AA and dynamic arrays) are
reference types. If you copy the associative array, you just copy the
references and any change in one will affect the other. Also,
internally:
alias int[][][string] MyArray;
void main()
{
MyArray foo;
foo["abc"] = [[0,1,2], [3,4], []];
assert(foo["abc"][0][1] == 1);
// internal copy
foo["def"] = foo["abc"];
foo["def"][0][1] = 2;
assert(foo["abc"][0][1] == 2);
// external copy
auto bar = foo;
bar["ghi"] = foo["abc"];
bar["ghi"][0][1] = 3;
assert(foo["abc"][0][1] == 3 && foo["def"][0][1] == 3);
}