On Wed, Nov 06, 2013 at 05:15:34PM +0100, Gary Willoughby wrote:
> A simple request but i'm failing hard. How do i re-init an
> associative array?
[...]

Just assign null to it:

        import std.stdio;
        void main() {
                int[string] aa;
                aa["a"] = 1;
                aa["b"] = 2;
                writeln(aa);

                aa = null;
                aa["a"] = 2;
                aa["b"] = 1;
                writeln(aa);
        }

Output:

        ["a":1, "b":2]
        ["a":2, "b":1]

The GC will take care of cleaning up the old data.


T

-- 
Don't get stuck in a closet---wear yourself out.

Reply via email to