privateAll

From Bohemia Interactive Community
Revision as of 17:09, 30 October 2023 by Leopard20 (talk | contribs) (Created page with "{{RV|type=command |game1= arma3 |version1= 2.16 |gr1= Variables |descr= Disables the implicit inheritance of local variables, as defined in the parent scope.<br> By default...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Hover & click on the images for description

Description

Description:
Disables the implicit inheritance of local variables, as defined in the parent scope.
By default, any local variables defined in a parent scope are available to the lower scope code.
After using privateAll, parent scope variables can no longer be accessed implicitly. However, it is still possible to explicitly access parent scope variables using the import command.
Groups:
Variables

Syntax

Syntax:
privateAll
Return Value:
Nothing

Examples

Example 1:
_a = 1; _b = 2; _c = 3; 4 call { // _a, _b and _c from the parent scope are accessible at this point systemChat str [_a, _b, _c]; // prints [1, 2, 3] privateAll; // _a, _b and _c from the parent scope can no longer be accessed systemChat str [_a, _b, _c]; // prints [Any, Any, Any] import ["_a", "_b"]; // _a and _b are now defined as private variables in the current scope; _c is still not defined systemChat str [_a, _b, _c, _this]; // prints [1, 2, Any, 4] _a = _a + 1; // changes the private _a variable in the current scope, but doesn't change the parent scope _a }; systemChat str _a; // _a is still 1

Additional Information

See also:
import private Variables#Scopes

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