Skip to content
Kavachकवच

Operators: Assignment

● Beginner2 min

= gives a variable a new value; += and the others change it in place.

fn main() {
    let score = 10
    score = score + 5
    score *= 2
    score -= 1
    print(score)
}

The program ran and printed:

kavach run change.kav

29
change.kav: Kavach code, then what running it prints

score += 5 means score = score + 5. Only a let can be assigned to.