Jump to content
Fiddi

[SOLVED] How do I check if {} is empty?

Recommended Posts

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

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

You mean like this?

_someCode = {};
_isEmpty = if (_someCode isEqualTo {}) then {true} else {false};
  • Like 2

Share this post


Link to post
Share on other sites

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

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

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

 

You mean like this?

_someCode = {};
_isEmpty = if (_someCode isEqualTo {}) then {true} else {false};
_someCode = {};
_isEmpty = _someCode isEqualTo {};
  • Like 1

Share this post


Link to post
Share on other sites

:) 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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×