def map = [x:10, 'z':20]
println map
resultado -> ["x":10, "z":20]
println map.x
->10
println map['x']
->10
printl nmap.keySet()
->["x", "z"]
Map map = [1: "Uno", 2:"Dos" , 3:"Tres"]
otras asignaciones
map = [:]
map[1] = 'a'
map[2] = 'b'
map[true] = '1'
map[false] = '0'
iterar un map
mMap.each{ key, value ->println "$key : $value"}
No hay comentarios:
Publicar un comentario