def someMap = [
           'phones':['iPhone','Galaxy','Nexus'],
           'laptops':['HP','MacBook','Samsung'],
           'tablets':['Galaxy Tab','iPad','Asus'],
           ]

someMap.eachWithIndex{ k, v, index -> println "${k}:${v} - ${index}" }


Result:
phones:[iPhone, Galaxy, Nexus] – 0
laptops:[HP, MacBook, Samsung] – 1
tablets:[Galaxy Tab, iPad, Asus] – 2

def map = [a:"cc", b: "dd"]
println "map - " + map
println "map.keySet() - " + map.keySet()
println "map.values() - " + map.values()
println "map.entrySet() - " + map.entrySet()
println "map.entrySet().key - " + map.entrySet().key
println "map.entrySet().value - " + map.entrySet().value


Result:
map – [a:cc, b:dd]
map.keySet() – [a, b]
map.values() – [cc, dd]
map.entrySet() – [a=cc, b=dd]
map.entrySet().key – [a, b]
map.entrySet().value – [cc, dd]

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required