On Wednesday, 6 January 2016 at 12:19:45 UTC, Jacob Carlborg
wrote:
On 2016-01-05 15:44, Minas Mina wrote:
It won't, but to use it again you need to allocate a new one
(If I'm not
mistaken).
Not explicitly. I don't know if the runtime allocates a new
one. This works:
void main()
{
auto foo = ["foo" : 1];
foo = null;
foo["bar"] = 2;
assert(foo["bar"] == 2);
}
I believe it does, check out this example:
import std.stdio;
class C
{
int[int] squares;
}
void main()
{
auto squares = [0 : 0, 1 : 1];
C c = new C();
c.squares = squares;
writeln(c.squares is squares); // true
squares = null;
squares[10] = 100;
writeln(c.squares is squares); // false
}
If the runtime used the same underlying memory, the second
writeln() would print true, right?
So if I am correct, a new AA is allocated.