[Grails/Groovy]minimum value of Map entries -


query: how can pull minimum value map in grails

so far have found following code minimum value map in groovy

["java":1, "groovy":4, "javascript":2].min{it.value} 

but donot work in grails

i have tried following piece of code

def map = ["java":1, "groovy":4, "javascript":2] println map.min{it.value} assert map.min{it.value}==1 

thanks in advance

if want minimum value map, can do:

def map = ["java":1, "groovy":4, "javascript":2] println map.values().min() assert map.values().min() == 1 

edit

also, closure accepting version of map.min has been in groovy since 1.7.6, , grails (as of v1.3.6) uses groovy 1.7.5


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -