BIS fnc setToPairs: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *R([a-z ])" to "$1 - r$2")
 
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.00


| arma3 |= Game name
|gr1= Arrays


|1.00|= Game version
|descr= Works similar to the [[BIS_fnc_addToPairs]] but it doesn't try to add values. It just overwrites the volue if the key already exists.
____________________________________________________________________________________________


| <pre>/*
|s1= [array, key, newValue] call [[BIS_fnc_setToPairs]]


Description:
|p1= array: [[Array]] - array to search through
Sets an item in pair array to given value.


Remarks:
|p2= key: [[String]] - key to search for
Works similar to the BIS_fnc_addToPairs but it doesn't try to add values. It just overwrites the volue if the key already exists.


Example:
|p3= newValue: [[Anything]] - (Optional, default 1) new value set if match was found
[["apple",3],["pear",10]] = [[["apple",3],["pear",2]],"pear",10] call BIS_fnc_setToPairs;
*/


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
|r1= [[Array]] - resulting modified array
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_setToPairs]]; --> |= Syntax
|x1= <sqf>[[["apple",3],["pear",2]],"pear",10] call BIS_fnc_setToPairs; // Returns [["apple",3],["pear",10]]</sqf>
 
|p1= |= Parameter 1
 
| |= Return value
____________________________________________________________________________________________
 
|x1= <code></code> |=
____________________________________________________________________________________________
 
| |= See also


|seealso= [[find]] [[findIf]] [[BIS_fnc_findInPairs]] [[BIS_fnc_getFromPairs]] [[BIS_fnc_addToPairs]] [[BIS_fnc_removeFromPairs]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Arrays|{{uc:setToPairs}}]]
[[Category:Functions|{{uc:setToPairs}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:setToPairs}}]]

Latest revision as of 16:47, 8 November 2023

Hover & click on the images for description

Description

Description:
Works similar to the BIS_fnc_addToPairs but it doesn't try to add values. It just overwrites the volue if the key already exists.
Execution:
call
Groups:
Arrays

Syntax

Syntax:
[array, key, newValue] call BIS_fnc_setToPairs
Parameters:
array: Array - array to search through
key: String - key to search for
newValue: Anything - (Optional, default 1) new value set if match was found
Return Value:
Array - resulting modified array

Examples

Example 1:
[[["apple",3],["pear",2]],"pear",10] call BIS_fnc_setToPairs; // Returns [["apple",3],["pear",10]]

Additional Information

See also:
find findIf BIS_fnc_findInPairs BIS_fnc_getFromPairs BIS_fnc_addToPairs BIS_fnc_removeFromPairs

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note