import Foundation
func stdWeight(hegihtCm height:Double, #bmi:Double) - > Double {
return power(height/100.0,2)*bmi
}
let height = 180.0
let w1 = stdWeight (hegihtCm:height, bmi:22.0)
print("The standard weight for a person who is \(height)cm is \(w1)kg.")
When you try to publish the external and internal arguments with the same name,
Expected parameter name followed by ':'
at #bmi in line 3
There is an error.
I am writing to ask you a question because I did not know how to solve the problem after searching.
If you know this compilation error, please let me know.
You know how to write a very old Swift.The current Swift (2.0 and later) commonizes the rule that all (*) parameters have argument labels (external names) by default in both functions and methods, so writing using #
has been removed.(*Swift2 only treats the first argument separately.)
Simply remove #
.
funcstdWeight(hegihtCm height:Double, bmi:Double) - > Double {
return power(height/100.0,2)*bmi
}
© 2024 OneMinuteCode. All rights reserved.