I have a list of cards as shown below:
List mapOne = [[hi:1], [hello:2],[xyx:4]]
This card needs to be converted to one card as shown below
Map resultMap=[hi:1, hello:2,xyx:4]
Are there any built-in functionality in Groovy?
Just do:
Map resultMap = mapOne.collectEntries()
Another option sum :
sum
groovy:000> [[hi:1], [hello:2], [xyx:4]].sum() ===> [hi:1, hello:2, xyx:4]