I’m trying to use a boolean array for some initialization and I ran into something I find rather misleading:
bool boolA = false;
bool boolB = boolA;
boolB = true;
Debug.Log(boolB + ", " + boolA); // Prints "True, False"
bool[] arrayBoolA = new bool[] { false };
bool[] arrayBoolB = arrayBoolA;
arrayBoolB[0] = true;
Debug.Log(arrayBoolB[0] + ", " + arrayBoolA[0]); // Prints "True, True"
For some reason in the second test, the boolean array seems to behave as if it was declared by reference, can someone clarify this point?