Reputation: 227
I have key-value pair as UUID's and trying to get key for process but it is returning value in the loop. Please help how to get key map ?
Input Value :
mapValues = [88891108-2dfd-41a1-9a92-f2200acc561c:12fd254d-98d0-4c0e-9ac9-9ccd5494075a]
code:
for(mapKey in sourceCodeMap.keySet())
{
println(sourceCodeMap[mapKey])
}
output:
12fd254d-98d0-4c0e-9ac9-9ccd5494075a
But iam expecting 88891108-2dfd-41a1-9a92-f2200acc561c as key. How to get left most value as key from map ?
Upvotes: 0
Views: 115
Reputation: 2133
The Groovy idiom is to use .each()
to iterate the map:
def mapValues = ['88891108-2dfd-41a1-9a92-f2200acc561c':'12fd254d-98d0-4c0e-9ac9-9ccd5494075a']
mapValues.each { key, value ->
println key
}
Upvotes: 2