groovy Collection Operators Build a map from two lists


Example

nrs = [1, 2, 3, 4, 5, 6, 7, 8, 9]
lets = ['a', 'b', 'c', 'd', 'e', 'f']

println GroovyCollections.transpose([nrs, lets])
        .collect {le -> [(le[0]):le[1]]}.collectEntries { it }

or
   
println [nrs,lets].transpose().collectEntries{[it[0],it[1]]}

// [1:a, 2:b, 3:c, 4:d, 5:e, 6:f]