/ Operators
Documentation

Getting Started

Language Guide

SDL2 and Graphics

CLI Reference

Operators

Vexel supports arithmetic, comparison, logical, and compound assignment operators. Operator precedence follows standard mathematical conventions.

Arithmetic Operators

+ Addition a + b
- Subtraction a - b
* Multiplication a * b
/ Division (integer or float) a / b
% Modulo (remainder) a % b
let a: int = 10
let b: int = 3
print(a + b)   # 13
print(a - b)   # 7
print(a * b)   # 30
print(a / b)   # 3 (integer division truncates)
print(a % b)   # 1

Comparison Operators

Comparison operators return a bool.

== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
let x: int = 5
print(x == 5)   # true
print(x != 3)   # true
print(x < 10)   # true
print(x >= 5)   # true

Logical Operators

and Logical AND — true if both operands are true
or Logical OR — true if at least one operand is true
not Logical NOT — inverts a boolean value
let a: bool = true
let b: bool = false
print(a and b)   # false
print(a or b)    # true
print(not a)     # false

Compound Assignment

Compound assignment operators modify a variable in place.

+= Add and assign x += 5 is x = x + 5
-= Subtract and assign x -= 5 is x = x - 5
*= Multiply and assign x *= 2 is x = x * 2
/= Divide and assign x /= 2 is x = x / 2

Ternary Expression

The ternary expression evaluates to one of two values based on a condition. The syntax is value_if_true if condition else value_if_false.

let x: int = 10
let label: str = "big" if x > 5 else "small"
print(label)   # big
← Variables and Types Functions →