Skip to content
ffredyk edited this page Jul 23, 2026 · 1 revision

nil

Category

Value Constructor

Arity

Nular — no operands.

nil

Description

Returns the nil value — SQ#'s representation of "nothing." Nil serves as the null/undefined sentinel. Assigning nil to a variable deletes the variable entirely (matching Arma SQF behavior). nil is still valid as an array element and as a return value from functions.

How It Works

nil is compiled to a nular command that pushes the singleton nil value onto the VM stack. It has no runtime cost beyond the push. In comparisons, nil compares equal only to itself.

Usage

Deleting variables

_myVar = 42;
_myVar = nil;       // _myVar no longer exists — variable deleted

Sentinel value in arrays

_arr = [1, nil, 3];
if (_arr select 1 == nil) then {
    systemChat "Slot is empty";
};

Default return from void functions

_doNothing = {
    // no return statement → returns nil
};
_result = call _doNothing;   // _result is nil

Checking for unset values

if (isNil "_myGlobal") then {
    _myGlobal = "default";
};

Thread Safety

ReadOnly — nil is a singleton immutable value. Safe from any scheduler.

See Also

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally