Does Groovy have method to merge 2 maps?
You can use plus:
assert [ a: true, b: false ] + [ a: false ] == [ a: false, b: false ]
Or left shift:
assert [ a: true, b: false ] << [ a: false ] == [ a: false, b: false ]
The difference is that <<
adds the right hand map into the left hand map. When you use +
, it constructs a new Map based on the LHS, and adds the right hand map into it