This language bar is your friend. Select your favorite languages!
Select your favorite languages :
  • Or search :

Idiom #298 Copy a map

Create the map y by cloning the map x.

y is a shallow copy, not a deep copy.

var y = Map.of(x);
y := make(map[K]V, len(x))
for k, v := range x {
	y[k] = v
my %y = %x;
y = x.copy()
y = x.dup

New implementation...