Posting to see whether anybody has come up with a solution to this, which appears to be a fundamental flaw in Zoho Deluge.
Try this code:
//testing nested maps with updated values.
ParentMap = Map();
ChildMap = Map();
ChildMap.put("Item1","Value 1");
ParentMap.put("First child item", ChildMap);
info "Parent map is: " + ParentMap;
ChildMap.clear();
info "After clearing the ChildMap only, the Parent map is: " + ParentMap;
ChildMap.put("Item2", "Value 2");
ParentMap.put("Second child item", ChildMap);
info "After adding a second ChildMap item, Parent map is: " + ParentMap;
The output is:
Parent map is: {"First child item":{"Item1":"Value 1"}}
After clearing the ChildMap only, the Parent map is: {"First child item":
{}
}
After adding a second ChildMap item, Parent map is: {"First child item":{
"
Item2":"Value 2
"},"Second child item":{"Item2":"Value 2"}}
Note the
two red sections. In the first one, although we have not changed the variable ParentMap, the 'child' element of it has been cleared entirely. In the second example, it is repopulated with the previous 'first' Child, but with different values (value 2)!
Can anybody explain why this happens? It feels contrary to all programming languages I have used in the past. Is this a pointer flaw in Zoho Deluge somewhere?
Thanks,
CR.