Clearing associative array.
ciechowoj via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Mar 12 04:59:02 PST 2016
On Saturday, 12 March 2016 at 12:42:04 UTC, Adam D. Ruppe wrote:
> On Saturday, 12 March 2016 at 12:34:16 UTC, ciechowoj wrote:
>> If above doesn't work how am I supposed to clear the array? `x
>> = string[string].init;` is somewhat ugly.
>
> Read the Tip of the Week section here:
>
> http://arsdnet.net/this-week-in-d/dec-13.html
>
> Short answer: use `= null` to clear the AA. [] doesn't work
> just because the compiler is a bit stupid about the type you
> intend it to be, but null works fine.
>
> BTW you might want to glance through more of the issues for the
> tip section too and see if there's more that interest you.
Nice article :), thanks. But still, what about clear()? In the
documentation https://dlang.org/spec/hash-map.html#properties
there is written that associative arrays have clear property.
More information about the Digitalmars-d-learn
mailing list