{"name":"isEqualTo","operator":null,"title":"isEqualTo","type":"command","url":"https://community.bistudio.com/wiki/isEqualTo","revid":336361,"updated":"2022-12-29T09:01:58Z","groups":["Variables"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.16"}],"since":{"game":"arma3","name":"Arma 3","version":"1.16"},"arma3_since":"1.16","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Performs strict comparison between var1 and var2 and returns true if equal, otherwise false. Strict means that it would check that both arguments are of the same data type and then compare the values.\n\nSome differences between isEqualTo and ==:\n- It performs case sensitive comparison on Strings\n- It doesn't throw error when comparing different types, i.e. (\"eleven\" isEqualTo 11)\n- It can compare Arrays, Script Handles and Booleans (alive player isEqualTo true)\n- It can compare non-existent game objects (grpNull isEqualTo grpNull)\n- It is slightly faster than ==, especially when comparing Strings\n- Arma 3 v1.48 It can compare Namespaces\n\n> [!NOTE]\n> A compiled code is not equal to the same compiled code made final: \n>\n> ```sqf\n> _a = compile \"123\"; _b = compileFinal \"123\"; _a isEqualTo _b; // false\n> ```\n\n> [!WARNING]\n> When comparing Arrays, if an array contains nil element, the comparison will return false. For example:\n>\n> ```sqf\n> private _array1 = [1, nil, 2];\n> private _array2 = [1, nil, 2];\n> _array1 isEqualTo _array2; // false\n> ```\n>\n> UNLESS the compared arrays are the same array:\n>\n> ```sqf\n> private _array1 = [1, nil, 2];\n> private _array2 = _array1;\n> _array1 isEqualTo _array2; // true\n> ```\n>\n> See: isEqualRef and BIS_fnc_areEqual vs BIS_fnc_areEqualNotNil","syntaxes":[{"syntax":"val1 isEqualTo val2","since":null,"effect":null,"exec":null,"params":[{"name":"val1","type":"Anything","optional":false,"default":null,"description":null,"types":["Anything"],"since":null,"text":"val1: Anything"},{"name":"val2","type":"Anything","optional":false,"default":null,"description":null,"types":["Anything"],"since":null,"text":"val2: Anything"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"binary","operator":null,"left":{"text":"val1","types":["Anything"]},"right":{"text":"val2","types":["Anything"]}}],"examples":[{"text":"```sqf\n_arr1 = [1, [2, [3]]];\n_arr2 = [1, [2, [3]]];\nif (_arr1 isEqualTo _arr2) then { hint \"Arrays match!\" };\n```","code":["_arr1 = [1, [2, [3]]];\n_arr2 = [1, [2, [3]]];\nif (_arr1 isEqualTo _arr2) then { hint \"Arrays match!\" };"]},{"text":"```sqf\nif (a isEqualTo b) then { hint \"a is equal to b\" };\nif !(a isEqualTo b) then { hint \"a is not equal to b\" };\n```","code":["if (a isEqualTo b) then { hint \"a is equal to b\" };\nif !(a isEqualTo b) then { hint \"a is not equal to b\" };"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["isNotEqualTo","isEqualRef","isEqualTypeAll","isEqualTypeAny","isEqualType","isEqualTypeParams","isEqualTypeArray","a == b","Operators"],"notes":[{"user":"Tajin","date":"","text":"Simply put, \"isEqualTo\" is a binary comparison. Therefor it is very fast but only accepts **100%** identical matches. In some other languages this is known as \"===\" instead of \"==\"."},{"user":"Dedmen","date":"","text":"When comparing with nil result is Nothing.\n\n```sqf\nnil isEqualTo player;\n```\n\nReturns Nothing instead of expected false\n\n```sqf\ndiag_log [nil isEqualTo player];\n```\n\nWill print `[bool]`"}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Variables","Introduced with Arma 3 version 1.16","Scripting Commands"]}