Variables and Types
Declaring variables
Variables are declared with the var keyword, followed by a type and a name:
Every variable must be initialized when declared.
Reassignment
After a variable is declared, you can reassign it without the var keyword:
Types
CColon has six built-in types:
int
64-bit signed integer.
| Property | Value |
|---|---|
| Size | 64 bits |
| Minimum value | -9,223,372,036,854,775,808 |
| Maximum value | 9,223,372,036,854,775,807 |
float
64-bit floating-point number (IEEE 754 double precision).
| Property | Value |
|---|---|
| Size | 64 bits |
| Precision | ~15 to 17 significant decimal digits |
| Minimum value | ~5.0 x 10^-324 |
| Maximum value | ~1.8 x 10^308 |
string
A sequence of characters, enclosed in double quotes.
Supported escape sequences:
| Escape | Character |
|---|---|
\n |
Newline |
\t |
Tab |
\\ |
Backslash |
\" |
Double quote |
bool
A boolean value, either true or false.
list
A dynamic, ordered collection of values. Lists can hold mixed types and grow or shrink at runtime.
See Lists and Arrays for more.
array
A fixed-size collection. Created with the fixed() function. Once created, the length cannot change.
See Lists and Arrays for more.
Type conversions
Values can be converted between types using built-in methods:
var int n = 42
var string s = n.tostring() // "42"
var float f = n.tofloat() // 42.0
var string numStr = "123"
var int parsed = numStr.toint() // 123
var float pf = numStr.tofloat() // 123.0
var float x = 3.7
var int truncated = x.toint() // 3
See Methods on Values for the full list.