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]