Is it possible to add a defer operator,
I propose to add this operator, for a delayed function / code call, which will be called after the execution of the function where it was called.
like defer in Golang
Is it possible to add a defer operator,
I propose to add this operator, for a delayed function / code call, which will be called after the execution of the function where it was called.
like defer in Golang
You can do this already
[ ]spawn { _thisScript spawn { waitUntil {scriptDone _this}; systemchat "runs last” }; systemChat "runs first"};
You can also do this using 2 helper functions, which is more optimal than using spawn with waitUntil:
//fn_deferrer.sqf params ["_params", "_code"]; private _deferred = []; _params call _code; { _x#0 call _x#1; } forEach _deferred
//fn_defer.sqf _deferred pushBack _this;
[[], { [[], {systemChat "runs last"}] call my_fnc_defer; systemChat "runs first"; }] call my_fnc_deferrer;