Nov 27 2016
(Swift 3) var a: Int = 15 var b: Int = 12 func swap( a: inout Int, b: inout Int){ (a, b) = (b, a) } print(“a is \(a) “) //15 swap(a: &a, b: &b) print(“a is \(a) “) //12 So far, so good. I really like that this is doing away with the extra […]
By Extelligent Cocoa • Wiki • • Tags: generics
Nov 27 2016
Basic (generic) swap function
(Swift 3) var a: Int = 15 var b: Int = 12 func swap( a: inout Int, b: inout Int){ (a, b) = (b, a) } print(“a is \(a) “) //15 swap(a: &a, b: &b) print(“a is \(a) “) //12 So far, so good. I really like that this is doing away with the extra […]
By Extelligent Cocoa • Wiki • • Tags: generics