0 votes
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?

in Engine by (215 points)

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.