If i have two list of maps in groovy...
def x = [ [a:1, b:2], [a:1, b:3], [a:2, b:4] ]
def y = [ [f:10, b:2, g:7], [f:100, b:3, g:8], [f:20, b:4, g:9] ]
How can I join them based on a particular attribute. In the above example the values for b
.
Desired result is...
[a:1, b:2, f:10, g:7]
[a:1, b:3, f:100, g:8]
[a:2, b:4, f:20, g:9]
I tried this but it's not exactly what I'm after.
def z = (x + y).groupBy { it.b }
z.each{ k, v -> println "${k}:${v}" }
thanks