我定义了两个 a = [[(k, *y) for y in v[0]] for k,v in d.items()]
a = [item for sublist in a for item in sublist]
ArrayList
。我希望将它们合二为一。
Maps
Expexted输出:
def arrayL1 = [name: "Smith", age: "2"]
def arrayL2 = [school: "School1", address: "Address1"]
答案 0 :(得分:1)
newArray = arrayL1.plus(arrayL2)
或
newArray = arrayL1 + arrayL2
应该做的伎俩
答案 1 :(得分:1)
您可以使用以下方法添加两张地图
1.Spread map operator
它允许您将地图的内容内联到另一个地图文字中,如下例所示:
Map map1 = [name: "Smith", age: "2"]
Map map2 = [school: "School1", address: "Address1", *:map1]
输出:
map2 = [name: "Smith", age: "2", school: "School1", address: "Address1"]
2.Plus运营商
Map mergedMap = map1 + map2
3.Plus方法
Map mergedMap = map1.plus(map2)