Skip to content

Variable

justinmann edited this page Dec 24, 2017 · 3 revisions

Variable types are automatically detected based on the value assigned

x := 0 // this will be type i32

There are two types of assignment to variables

  • mutable (can change) :=
  • immutable (cannot change) :

For example, this is okay

x := 0
x = 1

This is not

x : 0
x : 1  // Compiler error about double assignment

You should use : as much as possible, it is much easier for the compiler to optimize code that is immutable.

Clone this wiki locally