0Pricing
Mojo Academy · Lesson

Copies vs Shared State

When changes do and don't ripple out.

When Do Changes Spread?

Sometimes editing one variable also edits another, and sometimes it does not. The difference is copy versus shared state. 🔍

A Copy Is Self-Contained

When you get a copy, you hold separate data. Editing it cannot reach back and disturb the value you copied from.

var a = 1
var b = a
b = 2

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