Skip to content

Instantly share code, notes, and snippets.

@kssreeram
Created June 23, 2016 09:37
Show Gist options
  • Save kssreeram/891a0399661513bb70cf17c26aa6f72a to your computer and use it in GitHub Desktop.
Save kssreeram/891a0399661513bb70cf17c26aa6f72a to your computer and use it in GitHub Desktop.
Guess the output...
func test1(inout v:[Int], inout _ x:Int) {
v[0] += 1;
x += 1;
}
func test2(inout v:[Int], inout _ x:Int) {
v[0] += 1;
v.append(20);
x += 1;
}
var a = [10];
test1(&a, &a[0]);
var b = [10];
test2(&b, &b[0]);
print(a[0], b[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment