I'm trying to use the "copy dictionary" block in order to initialize specific different dictionaries to a master/template dictionary.
When I change the value of a key in one dictionary, the other one is affected as well.
This implies that the copy didn't work, and that the assignment is "by reference" and not "by value"...
OR: Am I missing something?
See mini-example: (The notifier prints both values as "true")
Thanks again for your efforts.
Well, your workaround makes the dictionary usage hard or even impossible in my app.
I have a complex dictionaries structure, with procedures that interact with the user, that result in some changes in the structure's values and also check some values during work.
The copy dictionary makes a deep copy of the given dictionary. This means that all of the values are copied recursively and that changing a value in the copy will not change it in the original.
Perhaps you can instead use the list blocks? There the "copy" works correctly. To retrieve an item use then "look up for pairs". If needed there are a few converting blocks in the "dictionary" collection between lists and dictionary.
I'll need to think about this. It's correct that as implemented the code only does a shallow copy (via HashMap's clone method). I'd have to go look at the feature branch development and see when we decided to change it from deep copy to shallow copy. I think at least part of the problem was to avoid the issues of having to clone cyclical structures, but I don't recall.