---
name: "Void"
type: topic
source: https://community.bistudio.com/wiki/Void
revid: 330443
updated: 2022-09-15T21:30:58Z
---

# Void

A [variable](../topics/Variables.md) of type **Void** is an **undefined variable**.

### Undefining Variables

[nil](../commands/nil.md) can be used to undefine variables.

```sqf
myVar = 1;
// ...
myVar = nil;
// myVar is undefined
```

### String Representation

The [String](../topics/String.md) representation of an undefined variable depends on its [inferred type](../topics/Void.md#type-inference):

| Data Type | [String](../topics/String.md) |
|---|---|
| [Anything](../topics/Anything.md) | scalar bool array string 0xfcffffef (OFP)<br>scalar bool array string 0xe0ffffef (ArmA) |
| [Nothing](../topics/Nothing.md) | scalar bool array string nothing 0xfcffffef |
| [Number](../topics/Number.md) | scalar |
| [Boolean](../topics/Boolean.md) | bool |
| [Array](../topics/Array.md) | array |

### Comparisons

No comparison with any variables will work.

**Example:**

```sqf
// error
if (undefinedVar == definedVar) then { /* ... */ };
```

```sqf
// error
if (undefinedVar == undefinedVar) then { /* ... */ };
```

### Detect an Undefined Variable

The [isNil](../commands/isNil.md) command, introduced in Armed Assault, allows to detect if a variable exists or not:

```sqf
HelloThere = 42;
isNil "HelloThere"; // false

HelloThere = nil;
isNil "HelloThere"; // true
```

#### isNil Workaround 1 (Operation Flashpoint v1.00)

SQS Syntax:

```sqs
_nil = format ["%1", _undefinedVariable]
? (format ["%1", variableToTest] == _nil) : hint "variableToTest is nil"
```

[SQF Syntax](../topics/SQF_Syntax.md):

```sqf
_nil = format ["%1", _undefinedVariable];
if (format ["%1", variableToTest] == _nil) then { hint "variableToTest is nil" };
```

#### isNil Workaround 2 (Operation Flashpoint v1.00)

> [!CAUTION]
> This information is **obsolete**. Armed Assault introduced [isNil](../commands/isNil.md), and Arma 2 forbade undefined variables usage in script - see ArmA: Editing#Forward Compatibility.

The alternative way to check if a variable is undefined before [isNil](../commands/isNil.md) existence is that it silently fails any expression evaluations on it:

```sqf
defined = false;
if (var == var) then
{
    defined = true;
};
if (var != var) then
{
    defined = true;
};
if (!defined) then
{
    // we know var is undefined here
};
```

### Type Inference

Suppose the variable **a** is undefined, and we set the variable **b** like so:

```sqf
b = a + [];
```

The inferred type of b is now array - since b was the product result of an array [add](../commands/~2B.md) operation with a definite array ([]) and an unknown type (a)

**b**'s string representation will now be "array", and b wil be considered an undefined array.

<sub>Source: [BI Community Wiki — Void](https://community.bistudio.com/wiki/Void) (revision 330443).</sub>
