Swift - Functions
What is wrong with this Swift code?
func doubleValue(_ num: inout Int) {
num *= 2
}
let fixedNum = 8
doubleValue(&fixedNum)What is wrong with this Swift code?
func doubleValue(_ num: inout Int) {
num *= 2
}
let fixedNum = 8
doubleValue(&fixedNum)inout Int, meaning it will modify the passed variable.fixedNum is declared as a constant with let, so it cannot be modified.var can be passed as inout parameters.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions