重点在&
1 func jiaohuan(inout a: Int,inout b: Int) 2 { 3 let temp = a 4 a = b 5 b = temp 6 } 7 var aa = 5 8 var a1 = 10 9 jiaohuan(&aa,b: &a1) 10 print("(aa),(a1)")
重点在&
1 func jiaohuan(inout a: Int,inout b: Int) 2 { 3 let temp = a 4 a = b 5 b = temp 6 } 7 var aa = 5 8 var a1 = 10 9 jiaohuan(&aa,b: &a1) 10 print("(aa),(a1)")