How i can clear Associative Arrays

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Apr 13 02:52:34 PDT 2013


On 4/13/13, gedaiu <szabobogdan at yahoo.com> wrote:
> looks great, but i cleared the array like this:
>
> values = null;

That's not clearing the array, that's clearing the reference to the
array. For example:

void main()
{
    int[int] hash;
    hash[1] = 1;

    auto hash2 = hash;  // new reference
    hash = null;  // clear the reference

    assert(1 in hash2);  // hash still exists
}


More information about the Digitalmars-d-learn mailing list