Velo by Example: Variables

In Velo, variables are explicitly typed. Every variable declaration includes its type.

Variables are declared with an explicit type and an initial value.

int x = 10;
str name = "Velo";

Variables can be reassigned to new values of the same type.

int a = 5;
a = 10;
a = a + 1;

Velo supports compound assignment operators for concise updates.

int a = 10;

a += 5;    # a = a + 5 → 15
a -= 3;    # a = a - 3 → 12
a *= 2;    # a = a * 2 → 24
a /= 4;    # a = a / 4 → 6
a %= 4;    # a = a % 4 → 2

The any type allows a variable to hold values of different types.

any value = 42;
value = "Hello";