How to assign variables a, b, c and d values to 1, 2, 3 and 4 through an array?
var a:Int = 0, b:Int = 0, c:Int = 0, d:Int = 0;
var array1:Array<Int> = [a, b, c, d];
var array2:Array<Int> = [1, 2, 3, 4];
for (i in 0...4)
array1[i] = array2[i]; //this does not work, it assigns array1's elements instead
trace(a); // this prints 0 instead of 1
trace(b); // 0 instead of 2
trace(c); // 0 instead of 3
trace(d); // 0 instead of 4
Aucun commentaire:
Enregistrer un commentaire