how to join list of maps in groovy -
if have 2 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 join them based on particular attribute. in above example values 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 it's not i'm after.
def z = (x + y).groupby { it.b } z.each{ k, v -> println "${k}:${v}" }
thanks
can't do:
[x,y].transpose().collect { a, b -> + b }
Comments
Post a Comment