How to copy a Map


#1

Hi,

How can I do a copy of a Map ‘a’ without keeping a reference to it.

var x = a // x is now referencing a
var y = clone(a) // y is still referencing a

The only solution I found was:

var z = Map()
a.for_each(fun(elem) {
z[elem.first] = elem.second;
});

Philippe