Skip to content
← Index | Lesson 4 of 5

Mutable Variables

Mutability

By default, variables are immutable. To create a variable that can be modified, use mut:

let mut counter = 0
counter = counter + 1
counter = counter + 1
print(counter) // 2

Goal: Create a counter, increment it 3 times and print the final value (3).

lesson-1-4.zolo
Program output

Run the code to see the output

Search Zolo

9 results

enespt-br