0Pricing
Mojo Academy · Lesson

Mutating in Place with inout

Let a function change the caller's value.

Sometimes You Must Change It

Borrowing only lets you read. But sometimes a function needs to actually modify the caller's value, like bumping a counter. ✏️

Meet inout

The inout convention gives a function mutable access. Changes you make inside are reflected back in the caller's variable.

All lessons in this course

  1. Borrowing Arguments Read-Only
  2. Mutating in Place with inout
  3. Taking Ownership with owned
  4. The Transfer Operator
← Back to Mojo Academy