← Back to Docs

Types

VDX supports four value types: int, float, string, and bool. You can optionally annotate variables with a type for runtime checking.

Value types

TypeExampleDescription
int42Whole numbers
float3.14Decimal numbers
string"hello"Text
booltrue / falseBoolean values

Float literals

Any number with a decimal point is a float:

let pi = 3.14;
let half = 0.5;
let five = 5.0;    // float, not int
print(pi);         // 3.14

Boolean literals

Use true and false directly:

let active = true;
let done = false;
if (active) {
    print("active!");
}

Type annotations

Add a type after the variable name with : to enable runtime type checking:

let count: int = 42;
let pi: float = 3.14;
let name: string = "VDX";
let ok: bool = true;

Type annotations are optional. Without them, variables accept any value.

Type mismatch errors

If the value doesn't match the annotation, VDX throws a runtime error:

let x: int = "hello";
// error: Type mismatch: expected 'int', got 'string'

The float annotation accepts both float and int values (widening).

Mixed arithmetic

When an int and float are used together in an operation, the result is automatically promoted to float:

print(10 + 3.5);    // 13.5
print(2 * 3.14);    // 6.28
print(7 / 2.0);     // 3.5

Truthiness

TypeTruthyFalsy
int!= 00
float!= 0.00.0
stringnon-empty""
booltruefalse
arraynon-empty[]
objectalways
voidalways