怎样安全地把一个数组复制到另一个数组,然后改动那个数组,原数组不变?
我试过把array_input的数据复制到array,但之后的操作,使array_input发生了变化。我用的方法如下:
array = []
for i in 0...array_input.size
array[i] = array_input[i]
end
之后都没有出现过array_input,但为何却使array_input改变了?怎样才是正确的方法?
我的言论只代表我个人的观点,不代表雇主及/或任何第三方的立场。
Opinions expressed are solely my own and do not express the views or opinions of my employer and/or any third parties. 捐赠 | GitHub
我的言论只代表我个人的观点,不代表雇主及/或任何第三方的立场。
Opinions expressed are solely my own and do not express the views or opinions of my employer and/or any third parties. 捐赠 | GitHub
我的言论只代表我个人的观点,不代表雇主及/或任何第三方的立场。
Opinions expressed are solely my own and do not express the views or opinions of my employer and/or any third parties. 捐赠 | GitHub