clear AAs

Bradley Smith digitalmars-com at baysmith.com
Tue Apr 17 17:35:44 PDT 2007


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);
}



More information about the Digitalmars-d-learn mailing list