0Pricing
Mojo Academy · Lesson

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 + 5

All lessons in this course

  1. What Value Semantics Means
  2. Copies vs Shared State
  3. Mojo's Safe Default
  4. A First Look at Mutation
← Back to Mojo Academy