A First Look at Mutation
Changing data without breaking other code.
Changing Data On Purpose
Independent copies are great, but real programs must mutate data: update a score, grow a list. Let us do it safely. ✏️
Mutating Your Own var
The simplest mutation is reassigning a var you own. Since it is your copy, the change affects only your value.
var score = 10
score = score + 5All lessons in this course
- What Value Semantics Means
- Copies vs Shared State
- Mojo's Safe Default
- A First Look at Mutation