I have a problem properly understanding map operations
def map1 = [ name: 'John']
def map2 = [ name: 'Jane']
assert [ name: 'Jane'] == map1 + map2
I would like to get a resulting map like
[[ name: 'Jane'], [ name: 'John']]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you do:
it combines the maps, with the right hand map overwriting any keys it has in common with the left hand map..
so:
What you want is a list of maps. One option is:
Which wraps map1 in a list, and then adds map2 to this list