On Saturday, 9 April 2016 at 18:06:52 UTC, Uranuz wrote:
Thanks. It's clear now. AA holds not `array struct` itself inside, but pointer to it.

How the array is stored in the AA doesn't matter, as far as I can see. The point is that you obtain a pointer to the array struct in the AA, not a copy.

If you had tried it like the following, mapElem would be a copy of the array struct in the AA, and the append would not affect mapka["item"]:
----
string[] mapElem = "item" in mapka ? mapka["item"] : (mapka["item"] = []);
mapElem ~= ["dog", "cat", "horse", "penguin", "fish", "frog"];
----

So reallocation affects ptr to allocated memory but not pointer to `array struct`. I think that's it.

Correct.

Reply via email to