How i can clear Associative Arrays

gedaiu szabobogdan at yahoo.com
Sat Apr 13 02:20:16 PDT 2013


On Saturday, 13 April 2013 at 09:09:36 UTC, Nicolas Guillemot 
wrote:
> Hey gedaiu,
>
> I'm still a novice to D, but here are some solutions I found. 
> They can probably be improved.
>
> 1) Assigning to it an empty map
> https://ideone.com/h7ffmD
>
> 2) Removing all entries
> https://ideone.com/E7k2WL
>
> My guess is that the first method is more efficient. I wish I 
> knew how to do it without having to explicitly declare the 
> "empty" variable.
>
> Cheers.

Hi,

string[string] empty;
values = empty;

looks great, but i cleared the array like this:

values = null;

and it seems it works great. But, i don't know how correct is 
this... I was expecting to have a clear() method on array.

Thanks,
Bogdan



More information about the Digitalmars-d-learn mailing list