0Pricing
Swift Academy · Lesson

In-Out Parameters and Multiple Returns

Mutating arguments with inout and returning multiple values via tuples.

Welcome

Swift functions normally work with copies of values. `inout` parameters let a function mutate the caller's variable directly. Tuples let functions return multiple values at once.

The inout Keyword

Mark a parameter `inout` to mutate the original: ```swift func doubleInPlace(_ value: inout Int) { value *= 2 } var x = 5 doubleInPlace(&x) print(x) // 10 ``` The `&` prefix at the call site signals the variable may be mutated.

All lessons in this course

  1. Argument Labels and Parameter Names
  2. Default and Variadic Parameters
  3. In-Out Parameters and Multiple Returns
  4. Functions as First-Class Values
← Back to Swift Academy