MAP :
x = [ 1 : "harish" , 2 : "viv" ]
public function() {
println x.1;
}
function()
brings error
whereas
x = [ id : "harish" , 2 : "viv" ]
public function() {
println x.id;
}
function()
works fine giving output harish
To solve the first problem we faced when we had integer as key
is
x = [ 1 : "harish" , 2 : "viv" ]
public function() {
println x.get(1);
}
function()
works fine giving output : harish
________________________________________________________________________________
Similarly
x = [ id : "harish" , 2 : "viv" ]
public function() {
println x.get(id);
}
function()
flings error
But
x = [ id : "harish" , 2 : "viv" ]
public function() {
println x.get("id");
}
function()
works fine giving output as harish