{"name":"break","title":"break","type":"command","url":"https://community.bistudio.com/wiki/break","revid":370194,"updated":"2024-11-06T11:55:55Z","groups":["Program Flow"],"status":"ok","games":{"arma3":"2.02"},"since":"arma3 2.02","arma3_since":"2.02","description":"Skips all loop iterations (for, forEach, while, findIf etc).","syntaxes":[{"syntax":"break","params":[],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"nullary"}],"examples":[{"text":"```sqf\n// prints 0, 1 and then exits\nfor \"_i\" from 0 to 3 do\n{\n    if (_i == 2) then { break };\n    systemChat str _i;\n};\n```","code":["// prints 0, 1 and then exits\nfor \"_i\" from 0 to 3 do\n{\n\tif (_i == 2) then { break };\n\tsystemChat str _i;\n};"]},{"text":"```sqf\nprivate _moneyHolder = objNull;\n{\n    if (\"Money_roll\" in items _x) then\n    {\n        _moneyHolder = _x;\n        break;\n    };\n} forEach units group player;\n\nif (isNull _moneyHolder) then\n{\n    hint \"We have to find this money.\";\n}\nelse\n{\n    hint format [\"%1 has the money!\", name _moneyHolder];\n};\n```","code":["private _moneyHolder = objNull;\n{\n\tif (\"Money_roll\" in items _x) then\n\t{\n\t\t_moneyHolder = _x;\n\t\tbreak;\n\t};\n} forEach units group player;\n\nif (isNull _moneyHolder) then\n{\n\thint \"We have to find this money.\";\n}\nelse\n{\n\thint format [\"%1 has the money!\", name _moneyHolder];\n};"]},{"text":"```sqf\n0 spawn\n{\n    private _value = 0;\n\n    while { _value < 10 } do\n    {\n        if (_value == 8) then\n        {\n            break; // 8 and 9 will never be printed\n        };\n\n        systemChat str _value ;\n        _value = _value + 1;\n    };\n};\n```","code":["0 spawn\n{\n\tprivate _value = 0;\n\n\twhile { _value < 10 } do\n\t{\n\t\tif (_value == 8) then\n\t\t{\n\t\t\tbreak; // 8 and 9 will never be printed\n\t\t};\n\n\t\tsystemChat str _value ;\n\t\t_value = _value + 1;\n\t};\n};"]}],"see_also":["continueWith","continue","breakWith","breakOut"]}