Function for

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Firty
var a:Int = 1
var b:Array = [0,0,0]
for x in b:
  x = a

expectation: b = [1,1,1]
reality: b = [0,0,0]

I have the impression that I already managed to do something similar that worked. in these cases I always have to use something like this:

var a:Int = 1
var b:Array = [0,0,0]
for x in range(b.size()):
  b[x] = a

I’m forgetting something? Or is it not possible to change b by manipulating the x as I did in the first example?

afaik it’s not possible to change the iterator reference directly.

Magso | 2020-10-30 19:08