nil: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 71: Line 71:
</dd>
</dd>
</dl>
</dl>
<dl class="command_description">
<dd class="notedate">Posted on April 08, 2016 - 21:35 (UTC)</dd>
<dd class="notedate">Posted on April 08, 2016 - 21:35 (UTC)</dd>
<dt class="note">'''[[User:Pierre MGI|Pierre MGI]]'''<dd class="note">
<dt class="note">'[[User:Pierre MGI|Pierre MGI]]</dt>
<dd class="note">
To illustrate Mikero's comment:
To illustrate Mikero's comment:
Destroying a variable doesn't mean the engine "reset" the "container" of the value. For example, just test:
Destroying a variable doesn't mean the engine "reset" the "container" of the value.
<code>
For example, just test:
<pre>
0 = [] spawn {  
0 = [] spawn {  
   while {true} do {
   while {true} do {
Line 84: Line 88:
     my_var = nil;
     my_var = nil;
}}
}}
</code>
</pre>
Container my_var is still incremented, even if value my_var is voided.
Container my_var is still incremented, even if value my_var is voided.
</dd>
</dd>
 
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->
}}

Revision as of 01:41, 9 April 2016

Hover & click on the images for description

Description

Description:
Nil value. This value can be used to undefine existing variables.
Groups:
Uncategorised

Syntax

Syntax:
nil
Return Value:
Void

Examples

Example 1:
variableToDestroy = nil;

Additional Information

See also:
isNilVariables

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

Notes

Mikero
Note that ArrayName = nil destroys the arrayNAME not the array content. Array content is 'destroyed' when no more ArrayNames refer to the content.
Worldeater
Never ever assign a value to nil! Doing so creates a global variable with the same name that overrides the "command" nil: foo = "foo"; nil = "bar"; foo = nil; hint foo; // displays "bar"

Bottom Section

Posted on September 25, 2014 - 09:50 (UTC)
Kenoxite
While isNil isn't available in OFP/CWA you can easily emulate it with something like this:
_nil = format["%1",_nilstring];
?(format["%1",foo]==_nil): foo = "Hello World!"
Posted on April 08, 2016 - 21:35 (UTC)
'Pierre MGI
To illustrate Mikero's comment: Destroying a variable doesn't mean the engine "reset" the "container" of the value. For example, just test:
0 = [] spawn { 
  while {true} do {
    sleep 0.5; 
    if (isNil "my_var") then {my_var = player addAction ["useless action", {}]};
    player removeAction  my_var;
    hintSilent format ["%1", my_var];
    my_var = nil;
}}

Container my_var is still incremented, even if value my_var is voided.