Casting an array form an associative array

Jacob Carlborg doob at me.com
Sat Nov 10 04:20:32 PST 2012


The following example:

void main()
{
     void[][size_t] aa;
     aa[1] = [1, 2, 3];

     if (auto a = 1 in aa)
     {
         writeln(*(cast(int[]*) a));
         writeln(cast(int[]) *a);
     }
}

Will print:

[1, 2, 3, 201359280, 0, 0, 0, 0, 0, 0, 0, 0]
[1, 2, 3]

The first value seems to contain some kind of garbage. Why don't these 
two cases result in the same value?

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list