examples/groovy/elements_of_map.groovy

def colors = [red: '#FF0000', green: '#00FF00', blue: '#0000FF']
println colors
println colors.containsKey('red')
println colors.containsKey('black')

for (p in colors) {
   println p.key
   println p.value
}

maps

g = [:]       // create map
println(g)

g['name'] = []   // create array
println(g)

g['name'].add("foo")
g['name'].add("bar")
println(g)

Return map from a function

examples/groovy/return_map.gvy

def f() {
  return ["a": 2, "b": 3]
}

r = f()
println r['a']
println r['b']