Hi, my question is fairly simple(or I hope it is), I want to compare the contents of one array to the contents of another; and if they are both equal, then execute the if… So, something like:
if(arrA == arrB)
print("Array A is equal to Array B");
But, sadly that does not work. Please can someone help me with this… perhaps ArrayUtility.Equals();
will do it? but I don’t know how to use that function…
Many thanks,
-TG106
Yes, Array Utility Equals compares the number of elements and checks if the contents are the same, returns true if both conditions are met as per the Array Equals.
if(ArrayUtility.ArrayEquals(arrA,arrB))
{
print("Array A is equal to Array B");
}
You can do it manualy if your array contains values:
var arraysAreEqual : boolean = true;
for(var i:int=0;i<arrA.length;i++)
{
if(arrA_!=arrB*)*_
{
arraysAreEqual = false;
break;
}
}
You can use this way too:
var arrA = new Array(1,2,3);
var arrB = new Array(1,2,3);
function Start(){
for(var i=0;i<arrA.length;i++){
if(arrA_.Equals(arrB*))*_
{
print(“Arrays are equal”);
}
}
}