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

== (Equal)

Category

Comparison

Arity

Binaryleft == right.

<any> == <any>

Description

Returns true if both operands are equal, false otherwise. For shared values, compares the unwrapped numeric values. For strings, uses ordinal comparison.

How It Works

The host re-registers == with enhanced behavior:

  • Shared values: unwraps and compares the underlying numbers.
  • Strings: ordinal (byte-by-byte) comparison.
  • Numbers: standard floating-point equality.
  • Nil: compares equal only to nil.
  • Arrays/HashMaps: reference equality (same object), not deep comparison.
  • Code: reference equality.

Usage

Basic equality

if (_hp == 0) then { handleDeath(); };
if (_name == "player") then { ... };
if (_flag == true) then { ... };

Nil check

if (_value == nil) then {
    _value = "default";
};

Shared value comparison

shared _counter = 0;
if (get _counter == 10) then {
    systemChat "Counter reached 10";
};

Array reference check

_arr1 = [1, 2, 3];
_arr2 = [1, 2, 3];
_arr1 == _arr2;            // false — different objects
_arr1 == _arr1;            // true — same reference

// For content comparison, iterate or use string conversion
str _arr1 == str _arr2;    // true — same content

Thread Safety

ReadOnly — pure comparison, no side effects. Safe from any scheduler.

See Also

  • != — not equal
  • < — less than
  • > — greater than
  • isNil — nil/undefined check
  • isNull — null/resolved check

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