Behaviour of AAs after initialization

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 7 11:57:14 PDT 2014


On 8/7/14, 10:35 AM, Puming wrote:
> On Thursday, 7 August 2014 at 16:53:24 UTC, H. S. Teoh via Digitalmars-d
>> It's really just the .init value of null which causes odd behaviour with
>> empty AA's. Fun fact:
>>
>>     void changeAA(int[string] aa) {
>>         aa["a"] = 123;
>>     }
>>
>>     // Null AA:
>>     int[string] aa1; // null
>>
>>     assert(aa1.length == 0);
>>     changeAA(aa1);    // no effect
> for most of the new users the WAT part is actually here :-)

One function we could and should use is one that makes an AA that is 
empty but not null. Right now one needs to use goofy methods such as 
adding and then removing a key. -- Andrei


More information about the Digitalmars-d mailing list