Skip to content
Matthew edited this page Jul 4, 2018 · 6 revisions

Variables in Jet

All types of variables in Jet can be defined using the 'let' keyword. The example below shows the definition of a variable of type int with the name 'x' and a value of 5:

let int x = 5;

Note that after the let keyword you can supply the type of the variable. This is not always necessary. The following code is also correct:

let x = 5;

It infers the type of the variable from the expression on the right, which happens to be int in this case.

It is also possible to define a variable and not assign a value to it, but when you do this you are required to specify a type.

let int x;

In this case it will be initialized to the default value or constructed if it happens to be of a struct type. These types will be discussed in a later section.

You can also declare sized or unsized array variables in the same fashion. More details about arrays can be found here.

let int[500] y;
let int[] z;
Clone this wiki locally