Jump to content
Sign in to follow this  
SRBuckey5266

What is the point of "bis_fnc_param"?

Recommended Posts

Is it supposed to be a replacement for "_this select 0"?

Are there any differences in speed?

Share this post


Link to post
Share on other sites

_this select 0 will always be faster due to the fact it's not doing anything else besides getting the 0 indexed element from _this.

However BIS_fnc_param has advantages to make your life easier:

  • Default values - Value to be used if a parameter is not defined. Useful for certain defaults and optional parameters.
  • Type checking - Requiring a parameter to be of a certain type(s). In case you need an object but someone passes in an int or a string, an error is shown.
  • Array length checking - If the parameter can take an array, check that it has a required amount of elements.

This way, you don't need to write code for these things yourself. More info here and here.

Edited by Sniperwolf572

Share this post


Link to post
Share on other sites

Like sniperwolf573 said, it's to make your life easier.

A good quote the wiki says "If you need to write it twice put it in a function".

Share this post


Link to post
Share on other sites

I find the functions makes setting default values for optional arguments easier.

_param0 = if (count _this > 0) then {_this select 0} else {false};

// is the same as 

_param0 = [_this,0,false] call BIS_fnc_param;

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
Sign in to follow this  

×