count = [:] count.test = 1 count.is = 2 ['this', 'is', 'a', 'test'].each { count[it] ? (count[it] += 1) : (count[it] = 1) } println count