Variadic and inout Parameters
A variadic parameter accepts many values. inout lets a function change the caller's variable, and you pass it with &.
Example
func sum(_ n: Int...) -> Int { n.reduce(0, +) }
func double(_ x: inout Int) { x *= 2 }
var v = 5
double(&v)
print(sum(1, 2, 3), v)Exercise
Pass by reference marker.
double(v)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.