[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
Post a Comment