0Pricing
Mojo Academy · Lesson

Copy vs Move Semantics

How values are duplicated or relocated.

Two Ways to Pass Along

When a value moves around your program, Mojo can either copy it or move it. Knowing which happens helps you reason about cost. 🔁

What a Copy Is

A copy makes a brand-new, independent value. Both the original and the copy live on, each owning its own data.

var a = MyType(1)
var b = a   # copy: a still valid

All lessons in this course

  1. Copy vs Move Semantics
  2. The __copyinit__ Method
  3. The __moveinit__ Method
  4. Destruction and __del__
← Back to Mojo Academy