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

isNull

Category

Type / Introspection

Arity

UnaryisNull <value>.

isNull <any>

Description

Checks whether a value is "null":

  • ScriptHandle: returns true if the handle has been resolved (the spawned code has finished or been terminated).
  • Nil: returns true (nil is null).
  • Other values: returns false.

This is the standard way to check if an async operation has completed.

How It Works

  • ScriptHandle: checks the internal IsResolved flag. Returns true if the handle is done.
  • Nil: returns true.
  • Everything else: false.

Usage

Check if async code finished

_handle = spawn { sleep 5; doWork(); };

// ... later ...
if (isNull _handle) then {
    systemChat "Work completed";
};

Wait loop

_handle = spawn { longOperation(); };
while { !isNull _handle } do {
    sleep 0.1;
};
systemChat "Done!";

With await (better alternative)

_handle = spawn { sleep 5; return 42; };
_result = await _handle;        // cleaner than polling isNull

Check finished before using result

if (isNull _handle) then {
    _result = get _handle;      // safe to get result
};

vs isNil

isNil nil;              // true
isNull nil;             // true

_handle = spawn { sleep 1; };
isNil _handle;          // false — handle exists
isNull _handle;         // false — handle not resolved yet

Thread Safety

ReadOnly — pure query. 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