Loading...

April 21, 2010

Groovy Goodness: Adding Maps to Map

Since Groovy 1.7.2 we can use the leftShift() method (<< operator) to add a map to another map.

def m = [name: 'Java', max: 10, sort: 'name']
def other = [name: 'Groovy', direction: 'asc']

m << other
assert [name: 'Groovy', max: 10, sort: 'name', direction: 'asc'] == m