If you store an array in a HashMap value and return it as deep copy, it still gets modified in the HashMap
Description
Description
Details
Details
- Severity
- None
- Resolution
- Not A Bug
- Reproducibility
- Always
- Operating System
- Windows 10 x64
- Operating System Version
- Newest
- Category
- Scripting
Steps To Reproduce
myHashmap = createHashmap; myHashmap set ["test", []]; private _myArray = + (myHashmap get "test"); _myArray pushBack "test";
hint str myHashmap
returns
[["test", ["test"]]];
it should be
[["test", []]]
only if I do this, it would be right:
private _myArray = (myHashmap get "test");
Event Timeline
Comment Actions
myHashmap = createHashmap; myHashmap set ["test", []]; private _myArray = + (myHashmap get "test"); _myArray pushBack "test"; myHashmap
No repro.
myHashmap = createHashmap; myHashmap set ["test", []]; private _myArrayRef = (myHashmap get "test"); private _myArray = + (myHashmap get "test"); _myArray pushBack "test"; _myArrayRef
No repro
myHashmap = createHashmap; myHashmap set ["test", []]; private _myArrayRef = (myHashmap get "test"); private _myArray = (myHashmap get "test"); _myArray pushBack "test"; _myArrayRef
works as intended.
Comment Actions
Found out that the problem was that it was not in brackets
private _myArray = + myHashmap get "test";
now it works.
private _myArray = + (myHashmap get "test");
Comment Actions
Of course, unary + has higher precedence than get, so it gets resolved first. https://community.bistudio.com/wiki/Operators#Order_of_Precedence