iOS ● ● ○ Swift 6

Kodebits Day 88: Inout Parameter

Sep 7 2026
Practice functions with a short swift challenge.

What is the output?

func double(_ n: inout Int) {
  n *= 2
}
var x = 5
double(&x)
print(x)
var y = 10
double(&y)
print(y)


Try it in the online Swift Playground →

[spoiler title="Solution"]

Answer:

10
20

Explanation:

inout parameters allow functions to modify the original variable.

[/spoiler]


Further Reading