clear AAs
Daniel Keep
daniel.keep.lists at gmail.com
Wed Apr 18 01:01:00 PDT 2007
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
--
int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
http://xkcd.com/
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d-learn
mailing list