Skip to content

Variables

Variables are used to store data. It’s declared using the var or val keywords, with var for mutable variables and val for immutable varaibles.

Variable type are specified by with the : type syntax after variable name. Manul supports type inference. An explicit type can be omitted if the variable has an initial value and the type can be unambiguously inferred.

The initial value is assigned using the = operator.

// Mutble variable with explicit type
var x: int = 1
// Immutable variable with inferred type
val y = 2
// Declared but not initialized variable
var z: int