How to re-initialise an associative array.
JR
zorael at gmail.com
Wed Nov 6 08:23:14 PST 2013
On Wednesday, 6 November 2013 at 16:15:36 UTC, Gary Willoughby
wrote:
> A simple request but i'm failing hard. How do i re-init an
> associative array? This is obviously not the way:
>
> import std.stdio;
>
> void main(string[] args)
> {
> int[string] x;
>
> x["hello"] = 1;
> x["world"] = 2;
>
> writefln("%s", x);
>
> x = new int[string];
>
> writefln("%s", x); // Should be empty.
> }
Maybe there's a neater way but x = x.init works.
More information about the Digitalmars-d-learn
mailing list