powershell 2D array: copying to another new array, change 1, another followed. - by Larry Song CN

Status : 


Sign in
to vote
ID 847443 Comments
Status Active Workarounds
Type Suggestion Repros 1
Opened 4/6/2014 12:29:59 AM
Access Restriction Public


Hi powershell developers,
not sure if this is a bug or not, i just paste the screenshot here, so you can know what happened.
i found i can't copy a 2D array to another array, if i changes value in the new array, the original one will also be changed.
Sign in to post a comment.
Posted by Nicolas Cloud surfer on 11/27/2015 at 7:57 AM
The most anoying problem is the different comportment between 1D array and 2D array clone() method. In 1D array the clone() method create a new instance while in 2D, the clone() method create a new reference without warning. A workaround should be to warn about this matter only when we use the method clone(). At least we can easely use the "=" to continue cloning reference instead cloning the instance.