Your solution is quite close. But the transpose only gives you the
tuples for label/value. If you need a fresh map with the keys, you have
to create it. E.g.
def labels=["math","science"]
def values=[90,80]
println([labels,values].transpose().collect{ label, value -> [label: label, value: value] })
// → [[label:math, value:90], [label:science, value:80]]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…