Update map using findAll and each in groovy

Viewed 17162

I would like to update values in map in Groovy filling certain criteria. Here is my code:

def m = [:]
m['a'] = 1
m['b'] = 2
m['d'] = 3
m.findAll { it.value > 1}.each { 
it.value = 4
}
println m

But the result is following:

[a:1, b:2, d:3]

Is there any way to do it using both findAll and each? Or I must use

m.each {if (it.value>1) it.value=4}
2 Answers
Related