nil: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(moving note to talk)
m (Void → Nothing, comment cleanup)
Line 2: Line 2:
____________________________________________________________________________________________
____________________________________________________________________________________________


| ofp |= Game name
| ofp |Game name=


|1.00|= Game version
|1.00|Game version=
____________________________________________________________________________________________
____________________________________________________________________________________________


| Nil value. This value can be used to undefine existing [[Variables|variables]]. |= Description
| Nil value. This value can be used to undefine existing [[Variables|variables]]. |Description=
____________________________________________________________________________________________
____________________________________________________________________________________________


| '''nil''' |= Syntax
| [[nil]] |Syntax=


| [[Void]] |= Return value
| [[Nothing]] |Return value=
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <code>variableToDestroy = [[nil]];</code> |= Example 1
|x1= <code>variableToDestroy = [[nil]];</code> |Example 1=
 
|x2= <code>[[private]] _variable = 50;
_variable = [[nil]];
[[hint]] [[format]] ["Variable = %1", _variable]; {{codecomment|// will display "Variable {{=}} any" ({{arma3}})}}</code> |Example 2=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[isNil]], [[Variables]] |= See also
| [[isNil]], [[Variables]] |See also=
 
}}
}}


Line 25: Line 28:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dt class="note">'''[[User:Mikero|Mikero]]'''<dd class="note">
Note that ArrayName = nil destroys the arrayNAME '''not''' the array content.
Array content is 'destroyed' when no more ArrayName'''s''' refer to the content.
<dt class="note">'''[[User:Worldeater|Worldeater]]'''<dd class="note">
'''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"


<!-- Note Section END -->
<!-- Note Section END -->
Line 50: Line 36:


[[Category:Scripting Commands|NIL]]
[[Category:Scripting Commands|NIL]]
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|NIL]]
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.46|NIL]]
[[Category:Scripting Commands ArmA|NIL]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on September 25, 2014 - 09:50 (UTC)</dd>
<dt class="note">[[User:Kenoxite|Kenoxite]]</dt>
<dd class="note">
While [[isNil]] isn't available in OFP/CWA you can easily emulate it with something like this:
<pre>
_nil = format["%1",_nilstring];
?(format["%1",foo]==_nil): foo = "Hello World!"
</pre>
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Revision as of 00:35, 27 May 2018

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

Examples

Example 1:
variableToDestroy = nil;
Example 2:
private _variable = 50; _variable = nil; hint format ["Variable = %1", _variable]; // will display "Variable = any" (Arma 3)

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

Bottom Section