The Transfer Operator
Move values with the ^ sigil.
The Transfer Operator is a free Mojo Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Mojo Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Move, Don't Copy
Passing to an owned parameter usually makes a copy. But if you are done with the original, copying is wasteful. You can move it instead. 🚚
Meet the Transfer Operator
Mojo's transfer operator is the caret ^ sigil. You place it after a value to hand its ownership over instead of duplicating it.
Using It in a Call
Add ^ when calling a function with an owned parameter. The value transfers in, and no copy is made.
var msg = String("hi")
consume(msg^)The Original Is Gone
After a transfer, the source variable is no longer valid. Mojo ends its lifetime, so you cannot accidentally use the moved value.
The Compiler Enforces It
Try to read a variable after moving it and the compiler rejects your code. This check stops use-after-move bugs before they run.
Why Moving Is Faster
A move just transfers ownership of the existing data. There is no deep copy, which matters a lot for big strings, lists, or buffers.
Copy or Move, Your Choice
Without ^ Mojo copies into an owned parameter; with ^ it moves. You decide based on whether you still need the original.
Transfer on Assignment
The caret also works between variables. Writing one var from another with ^ moves the value rather than copying it across.
var a = String("data")
var b = a^ # a is now invalidPairs With owned
The transfer operator is the natural partner of owned parameters. Together they express giving a value away cleanly and cheaply.
Safety Plus Speed
Moves give you C-like efficiency while the compiler guarantees you never touch a value after handing it off. That is safe and fast.
The Full Ownership Picture
borrowed, inout, owned, and the ^ transfer together let you control exactly how data flows through your program, with no surprises.
Quick Check
Let us check what the ^ operator does to the source.
Recap
The ^ transfer operator moves a value instead of copying it, ending the source's life. Paired with owned, it makes giving data away fast and safe. 🎯
Frequently asked questions
Is the “The Transfer Operator” lesson free?
Yes — the full text of “The Transfer Operator” is free to read here on the web, and the Mojo Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Mojo Academy course, upgrade to CoddyKit PRO.
What will I learn in “The Transfer Operator”?
Move values with the ^ sigil. You practise Mojo Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Mojo Academy?
No prior experience is required. Mojo Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The Transfer Operator” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Mojo Academy lesson?
Yes. Every Mojo Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Borrowing Arguments Read-Only
- Mutating in Place with inout
- Taking Ownership with owned
- The Transfer Operator