Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #334 Combine 2 maps

Create the new map c containing all of the (key, value) entries of the two maps a and b.

Explain what happens for keys existing in both a and b.

%c = (%a, %b);
final c = {...a, ...b};
c := make(M, len(a)+len(b))
for k, v := range a {
	c[k] = v
}
for k, v := range b {
	c[k] = v
}
let c = {...a, ...b}
c = {**a, **b}
c = a | b
c = a.merge(b)

New implementation...
programming-idioms.org