openList = Array([1,1], [2,3], [4,5]);
containss = function (input, arrayData, tellID) {
for (i = 0; i < arrayData.length; i++) {
if (arrayData[i] == input) {
if (tellID) {
return i;
} else {
return true;
}
}
}
return false;
}
trace(containss([2,3], openList, true));
This code returns false when openList contains 2,3. When I add trace(arrayData[i]), I get 1,1 2,3 4,5 and when I do trace(input) I get 2,3. What is wrong? Thanks
You are comparing 2 arrays using the equal operator:
This will always be false, no matter the contents of the arrays. The equal operator in your case tests if
arraydata[i]is the same object withinputnot if 2 different objects (arrays) have the same content.