{"name":"and","title":"and","type":"command","url":"https://community.bistudio.com/wiki/and","revid":349274,"updated":"2023-11-08T14:51:11Z","groups":["Variables","Math"],"status":"ok","games":{"ofp":"1.00","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.00","arma3_since":"0.50","description":"Returns true only if both conditions are true.\nIn case of the alternative syntax, [lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation#Control_structures) is used - if left operand is false, evaluation of the right side is ignored.","syntaxes":[{"syntax":"a and b","params":[{"name":"a","type":"Boolean","description":"test condition or variable","type_expr":"Boolean"},{"name":"b","type":"Boolean","description":"test condition or variable","type_expr":"Boolean"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"a"},"right":{"text":"b"}},{"syntax":"a and b","since":"arma2oa 1.62","params":[{"name":"a","type":"Boolean","description":"test condition or variable","type_expr":"Boolean"},{"name":"b","type":"Code","description":"code that returns Boolean. It is **not** evaluated if *a* is false","type_expr":"Code"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"a"},"right":{"text":"b"}}],"examples":[{"text":"```sqf\nif ((not isNull player) and (alive player) and (_enemycount == 0)) then\n{\n    hint \"you win !\";\n};\n```","code":["if ((not isNull player) and (alive player) and (_enemycount == 0)) then\n{\n\thint \"you win !\";\n};"]},{"text":"```sqf\nif ((count _array > 0) and { (_array select 0) == player }) then    // works as expected\n{\n    hint \"It works!\";\n};\n\nif ((count _array > 0) and (_array select 0) == player) then        // Error: _array select 0 is evaluated\n{\n    hint \"It... works?\";\n};\n```","code":["if ((count _array > 0) and { (_array select 0) == player }) then\t// works as expected\n{\n\thint \"It works!\";\n};\n\nif ((count _array > 0) and (_array select 0) == player) then\t\t// Error: _array select 0 is evaluated\n{\n\thint \"It... works?\";\n};"]}],"aliases":["a && b"],"see_also":["a && b","or","Operators"]}