Just wondering if anybody else finds this surprising:
So I need to do things this way, and then everything works fine:Code:var master:Array = [5,6,7,8,9]; var copy:Array = master; trace(copy); // 5,6,7,8,9 trace(master); // 5,6,7,8,9 copy[2] = 1001; trace(copy); // 5,6,1001,8,9 trace(master); // 5,6,1001,8,9 (original also changed)
So arrays behave very differently from 'normal' variables:Code:var master:Array = [5,6,7,8,9]; var copy:Array = [master[0],master[1],master[2],master[3],master[4]]; trace(copy); // 5,6,7,8,9 copy[2] = 1001; trace(copy); // 5,6,1001,8,9 trace(master); // 5,6,7,8,9 (original untouched)
Is this a 'Flash' thing, or do most programming languages work in this way?Code:var master:int = 56; var copy:int = master; copy = 1001; trace(copy); // 1001 trace(master); // 56
Just wondering, that's all.




Reply With Quote