BCW0006: WARNING: Assignment to temporary.

When the compiler goes through this javascript code, it gives me the warning
“BCW0006: WARNING: Assignment to temporary.” when I try to assign the z value of a Vector3

the only reference (useful) I found to this error is [this page][1] and it’s not terribly helpful.

`#pragma strict
class Premades
	 * Creates a Square piece where each block is a random color.
	static function square() : Vector3[,]
		var output : Vector3[,] = square(1);
		for(var first : int = 0; first < 1; first++)
			for(var second : int = 0; second < 4; second++)
				output[first, second].z = randomColor();//<----Throws the warrning here
		return output;                      //BCW0006: WARNING: Assignment to temporary.
	 * Creates a square piece where each block is a set color.
	static function square(c : int) : Vector3[,]
		var output : Vector3[,] = new Vector3[1,4];
		//              X,Y,color
		output[0,0] = V(0,0,c); //   
		output[0,1] = V(0,1,c); //   B B
		output[0,2] = V(1,0,c); //   O B
		output[0,3] = V(1,1,c);//    ^origin
		return output;
	 * There are better ways to get a random number.
	static function randomColor() : int
		var result = 1;
		switch (  Mathf.Floor(  Random.Range(0, 2.9999)  )  )
			case 0: result =  1; break;//red
			case 1: result =  2; break;//green
			case 2: result =  4; break;//blue
		return result;// If I try to return inside the switch block,
	}                   //It gives an unreachable code warning
	/** Because I'm too lazy to type out Vector3 */
	static function V(X : int, Y : int, Z : int) : Vector3
	{	return Vector3(X, Y, Z);	}

Can I ignore this warning? It compiles just fine, but will it actually assign the number correctly?

  [1]: http://permalink.gmane.org/gmane.comp.lang.boo.devel/5779

The reason why you are getting this warning is because a Vector3 is a structure. When you return a structure, you are actually returning a clone. See this blog page for the difference.

I suspect what is happening when you return the Vector from the output array, the complier will create a Vector3, copy the values to it and return it. You are assigning to this copy, hence the temporary assignment warning. The value is not being written back to the one in the array.