{"name":"a == b","operator":"==","title":"a == b","type":"command","url":"https://community.bistudio.com/wiki/a_%3D%3D_b","revid":369426,"updated":"2024-09-03T18:48:52Z","groups":["Math","Variables"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Check if *a* is equal to *b*. String comparison is case-**in**sensitive  - use isEqualTo if case sensitivity is needed.\n\n> [!IMPORTANT]\n> *a* and *b* types **must** match: comparing e.g String with Number is invalid.","syntaxes":[{"syntax":"a == b","since":null,"effect":null,"exec":null,"params":[{"name":"a","type":null,"optional":false,"default":null,"description":"| Introduced in | Operation Flashpoint v1.00 | Armed Assault v1.00 | Armed Assault v1.08 | Arma 3 v2.00 |  |  |  |  |  |  |  |  |  |\n|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n| Possible Type | Number | Side | String | Object | Group | Structured Text | Config | Display | Control | Location | Diary Record | Namespace | Boolean |","types":[],"since":null,"text":"a:\n\n| Introduced in | Operation Flashpoint v1.00 | Armed Assault v1.00 | Armed Assault v1.08 | Arma 3 v2.00 |  |  |  |  |  |  |  |  |  |\n|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n| Possible Type | Number | Side | String | Object | Group | Structured Text | Config | Display | Control | Location | Diary Record | Namespace | Boolean |"},{"name":"b","type":"identical to a's type","optional":false,"default":null,"description":null,"types":[],"since":null,"text":"b: identical to *a*'s type"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"binary","operator":"==","left":{"text":"a","types":[]},"right":{"text":"b","types":[]}}],"examples":[{"text":"```sqf\nif (player == leader group player) then\n{\n    hint \"You are the leader of your group.\";\n}\nelse\n{\n    hint \"Someone else is the boss\";\n};\n```","code":["if (player == leader group player) then\n{\n\thint \"You are the leader of your group.\";\n}\nelse\n{\n\thint \"Someone else is the boss\";\n};"]},{"text":"```sqf\n\"MyRabbit\" == \"MYRABBIT\"; // returns true\n```","code":["\"MyRabbit\" == \"MYRABBIT\"; // returns true"]},{"text":"```sqf\nif (alive _unit1 == alive _unit2) then { hint \"Both units are either dead or both alive\" };\n```","code":["if (alive _unit1 == alive _unit2) then { hint \"Both units are either dead or both alive\" };"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["a != b","Operators","isEqualTo"],"notes":[{"user":"ffur2007slx2_5","date":"2014-04-15T10:13:00Z","text":"For script comparison we need to detect whether scripts are running in advance, then compose both into string:\n\n```sqf\nif (scriptDone _var0) then [{false},{(str _var0) == (str _var1)}];\n```\n\nIt is recommended to use isEqualTo for all types comparison, which is more functional and as fast as operator.\nFor multiple comparisons:\n\n```sqf\nfnc_areEqual = {\n    private [\"_b\", \"_var1\", \"_var2\"];\n    _b = true;\n    for [{ _i = 1 }, { _i < (count _this) && _b }, { _i=_i + 1 }] do {\n        _var1 = _this select (_i-1);\n        _var2 = _this select _i;\n        if (!(_var1 isEqualTo _var2)) then { _b = false; };\n    };\n    _b\n};\n[\"A\",\"a\",\"a\"] call fnc_areEqual; // false\n```\n\nAnd we can use such workaround instead of using BIS_fnc_arrayCompare or BIS_fnc_areEqual"}],"categories":[]}