Methods with In/Out parameters in Swift
Forums:
func swapStrings(inout s1: String, inout _ s2: String) {
let tmp = s1
s1 = s2
s2 = tmp
}
var s1 = "A"
var s2 = "B"
swapStrings(&s1, &s2)
//s1 is "B", s2 is "A"
- Log in to post comments