Skip to main content
Version: 1.4.0

Mutating

In imperative programming, the state is modified in place by instructions, instead of new versions of values being constructed. A typical example of imperative programming is loops.

LIGO features mutable variables, that is, variables whose values can be reassigned --- contrary to constants, which can be only assigned once.

The declaration of mutable variables start with the keyword let, instead of const for constants. All assignments use the = operator, like so:

function add (a: int, b:int) : int {
let c = a + b; // not const!
c++; // Reassignment of incremented c
return c; // c == a + b + 1
};