Open
Description
I noticed this odd behaviour when making a game. I had an array of enemies, and iterated through them using a for...in loop, and noticed their x and y values did not change!
So I simplified things to demonstrate the behaviour, and came up with this:
arr = []
for i=1 to 3
local temp = {}
temp.x = i
arr << temp
next
print arr
for M in arr
M.x += 3
next
print arr
My output:
[{"x":1}, {"x":2},{"x":3}]
[{"x":1}, {"x":2},{"x":3}]
The second line should be [{"x":4},{"x":5},{"x":6}]
.
Metadata
Metadata
Assignees
Labels
No labels