Object assignment Lua

喜夏-厌秋 提交于 2019-12-05 02:01:36

I believe you may misunderstanding variable assignment in Lua. All variables are actually references/pointers to objects. When you write:

cells[ind1][ind2]=cells[ind3][ind4]

you are throwing away (removing a reference to) the object that was pointed to by cells[ind1][ind2], and you create a second reference to the object pointed to by cells[ind3][ind4].

If you put some stuff (like the properties you think are disappearing) in cells[ind1][ind2] before the assignment, it won't be there after the assignment because that variable is now pointing at a different object.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!