for loop problem

hello everyone, ive been away from unity for a while and im getting a bit of truble with a for loop, its supposed to fill an array with the distances at which to spawn objects, here is how it looks like:

	void Update () {
		for (int i = 0; i < 10; i ++){
			distPerSs _= -0.25f * i + 500;   //error here_

_ print("Pos: " + distPerSs*);_

its based in a linear function in which, if i = 0 the value of distPerSs would be 250, and if i = 1000 the distPerSs = 500, yet its giving me an error of “index out of range” in the marked line. any ideas and suggestions are much apreciated

Not sure what your want to do in detail but the error means you try to write or read data from an index that doesn’t exist.

e.g. if your array distPerSs has the length of 10 so you create it with this:
float distPerSs = new float[10];
then you can only use it with index 0 to 9 (distPerSs[0] to distPerSs[9]) but not distPerSs[10].

So the important part is how big is your list?
e.g. for the length 10 you could easily do this:

 float[] distPerSs = new float[10];//here you decide the length
 for (int i = 0; i < distPerSs.Length; i ++) //using distPerSs.Length instead of 10
     distPerSs _= -0.25f * i + 500;   //error here_

print("Pos: " + distPerSs*);*
If you do it like this you can change the length easily how you need it without breaking your loop