Fiddi 68 Posted May 3, 2016 Hey, I'm having trouble figuring out how to check if a "Code" type is empty. Is there a simple way to check that? Share this post Link to post Share on other sites
dscha 147 Posted May 3, 2016 erm, do you mean that: if bis_fnc_blabla is not existing -> Do that? If yes, this might be helpful: if(isNil "bis_fnc_blabla")then{dosomethingelsebecausetheotherfunctiondoesnotexists}; Share this post Link to post Share on other sites
Rydygier 1304 Posted May 3, 2016 You mean like this? _someCode = {}; _isEmpty = if (_someCode isEqualTo {}) then {true} else {false}; 2 Share this post Link to post Share on other sites
Fiddi 68 Posted May 3, 2016 Oh, so it is so simple as to just do isEqualTo {} Don't know why I didn't try it the first time. Though, what is more performance friendly, simply calling an empty code {} or checking if it's empty and then calling it or not? EDIT: Tested it with the debug console's performance tool. It's faster (and cleaner) just to call the empty code, about 0.0005 ms faster Share this post Link to post Share on other sites
Guest Posted May 3, 2016 Calling it may be faster. It does not inpact on performance. Calling an empty code will do nothing. Share this post Link to post Share on other sites
Fiddi 68 Posted May 3, 2016 Yes, since I don't want anything else to happen if it's empty then it works perfectly. Thanks for the help, everyone! Share this post Link to post Share on other sites
serena 150 Posted May 3, 2016 You mean like this? _someCode = {}; _isEmpty = if (_someCode isEqualTo {}) then {true} else {false}; _someCode = {}; _isEmpty = _someCode isEqualTo {}; 1 Share this post Link to post Share on other sites
Rydygier 1304 Posted May 3, 2016 :) Indeed. Alas, I've some tendencies to such "intellectual detours", which sometimes is funny, rarely useful, often annoying. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted May 3, 2016 Out of curiosity, for what specific case would you need that? Cheers Share this post Link to post Share on other sites
Fiddi 68 Posted May 3, 2016 Out of curiosity, for what specific case would you need that? Cheers I have a vehicle respawn function in which I can specify the initialization field of the vehicle that will be respawned, and the function is called with a parameter specifically for the init, defined in the params like so: params [ ["_vehicle", objNull, [objNull]], ["_delay", 10, [0]], ["_init", {}, [{}]], // this one ["_loadout", "", [""]], ["_cache", false, [true]] ]; I didn't want to lose performance or have it do unpredictable things, but since it works either way... Share this post Link to post Share on other sites