clear AAs
Max Samukha
samukha at voliacable.com
Wed Apr 18 01:36:41 PDT 2007
On Wed, 18 Apr 2007 18:01:00 +1000, Daniel Keep
<daniel.keep.lists at gmail.com> wrote:
>
>
>Bradley Smith wrote:
>> Mandel wrote:
>>> Hi,
>>>
>>> I have a simple question, how can I remove all elements of an
>>> associative array
>>> in an elegant way?
>>> The length property of an AA is read only.
>>> Doing a foreach/remove seems a bit to much text; most containers
>>> provide some clear method.
>>
>>
>> import std.stdio;
>>
>> void main() {
>>
>> bool[char[]] aa;
>> aa["abc"] = true;
>> aa["def"] = false;
>> writefln(aa);
>>
>> aa = aa.init;
>> writefln(aa);
>> }
>
>... that's so simple; why didn't I think of that before?!
>
>Thanks for that! :)
>
> -- Daniel
Or aa = null (aa.init == null)
More information about the Digitalmars-d-learn
mailing list