是否可以通过Groovy闭包或内置功能添加列表来实现?使用加法运算符会导致简单的列表连接。
def firstList = [1, 2, 3, 4]
def secondList = [5, 6, 7, 8]
def resultList = firstList + secondList // It has to be by elements addition closure here
assert resultList == [6, 8, 10, 12] // Assertion failed
答案 0 :(得分:4)
[ firstList, secondList ].transpose()*.sum()