I don't believe the (spartan) docs address this case: func foo(inout a: [Int], inout b: Int) { let acopy = a a = [4, 5, 6] print(acopy) // prints "[1, 2, 3]" b = 99 print(a) // prints "[4, 5, 6]" print(acopy) // prints "[1, 2, 99]" (e.g. a let variable changed!) }
var arr = [1,2,3] foo(&arr, b: &arr[2]) print(arr) // prints "[4, 5, 6]" Is this code "undefined", meaning the spec / doc doesn't specifically say what should be happening? For instance, I can't believe a let variable gets changed. The docs also say inout changes the original value when the function ends, not in the middle as is happening here. _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users