The __moveinit__ Method
Define how your type moves.
Defining How to Move
To move a value, Mojo calls a special method named __moveinit__. It builds a new instance by taking over an old one. 🚚
It Runs on Transfer
When you use the caret transfer operator, __moveinit__ fires. It relocates the value instead of duplicating its data.
var b = a^ # calls __moveinit__All lessons in this course
- Copy vs Move Semantics
- The __copyinit__ Method
- The __moveinit__ Method
- Destruction and __del__