Skip to content
cyxigo edited this page Jul 12, 2026 · 8 revisions

Values

Values are pieces of data in programming languages. They can be several types in Wi: real, null, bool, string, array, map, function, foreign, object and userdata.

Let's go through each one.

Real

A real number is any number. In Wi's implementation, it uses double-precision floating point format.

0
1234
0.4321
-124
-0.421
3.14159265359
1.0
0xcafebabe
0b01010101

Null

null represents nothing - an absence of a value.

null

Bool

Bool (short for boolean) can store only two values: true or false. They are used to indicate whether a condition is truthy or falsy.

true
false

String

A string is an immutable array of characters. Once created, you can access its characters via [], but you cannot mutate it.

"Hello World!"
"I love Wi"
"Meow"

Accessing characters:

"Hello"[0]; // H
"Hello"[4]; // o

Concatenation uses ..:

"Hello" .. " " .. "World"; // Hello World

And is able to work with any type:

1 .. null .. true .. "a string"; // 1nulltruea string

All string functions in Wi's standard library return a new string - they never modify the original.

Array

An array is a linear collection of data. Items are accessed via [i], where i is the index (0-based).

Arrays can be mutated:

var a = [1, 2, 3];
a[0] = 10; // [10, 2, 3]

Or using built-in functions:

var a = [1, 2, 3];
a->add(10); // [1, 2, 3, 10]
a->remove(2); // [1, 3, 10]

Accessing an index out of range will cause a runtime error:

var a = [];
a[0];
runtime error: array index out of range: 0
   --> file.wi:1 in main function

Map

Map is a non-linear collection of key-value pairs. Access values with [key]:

var m = { "x": 10 };
print(m["x"]); // 10

m["y"] = 20;
print(m["y"]); // 20

Accessing a key that does not exist will cause a runtime error:

var m = {};
print(m["x"]);
runtime error: key error
   --> file.wi:1 in main function

More complex values

They are function, foreign, object, and userdata. They all have their respective page because there's way more to talk about.

Clone this wiki locally