inout Parameters
inout lets a function change the caller variable. Pass with &.
Example
func double(_ n: inout Int) { n *= 2 }
var x = 5
double(&x)
print(x)Exercise
Pass by reference.
double(x)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.