0
Variable Parameters
Is it possible in swift 4.1 to Use the keyword var as a prefix to the parameter name to define a variable parameter? ex. func myFunc(var num1: Int, num2: Int) -> Int { num1 = num1 + num2 return num1 }
1 ответ
0
Argument of a function in Swift is let by default so change it to var if you need to alter the value i.e,
func reduceToZero(var x:Int) -> Int { while (x != 0) { x = x-1 } return x }