Groovy multiple assignment with a map

groovy, variable-assignment

Solution

Actually, you can do this if you cheat and use `.with`:

Map map = [a: 1, b:2]

map.with {
    (a, b) = [3, 4]
}

assert map.a == 3
assert map.b == 4

Problem

I am having a problem doing a multiple assignment statement for values in a map. ``` def map = [a:1,b:2] (map.a, map.b) = [3,4] ``` this throws an exception: ``` expecting ')', found ',' at line: 2, column: 7 ``` However, this works fine: ``` def a = 1 def b = 2 (a, b) = [3,4] ```

Original source