class GroovyTest {
static void main(args) {
def defaults = [1: 'a', 2: 'b', 3: 'c', 4: 'd']
def overrides = [1: 'z', 5: 'x', 13: 'x']
defaults.putAll(overrides)
print defaults
}
输出:
[1:z, 2:b, 3:c, 4:d, 5:x, 13:x]