java – for each loop in groovy
java – for each loop in groovy
as simple as:
tmpHM.each{ key, value ->
doSomethingWithKeyAndValue key, value
}
This one worked for me:
def list = [1,2,3,4]
for(item in list){
println item
}
Source: Wikia.
java – for each loop in groovy
You can use the below groovy code for maps with for-each loop.
def map=[key1:value1, key2:value2]
for (item in map) {
log.info item.value // this will print value1 value2
log.info item // this will print key1=value1 key2=value2
}