Swift 3.0 Update:
In swift 3.0, methods with one parameter name for each input are needed to have this parameter name as part of a function call. Therefore, if you define a function like this
func say(name:String, msg:String) { print("\(name) say \(msg)") }
Your function call should be like this
self.say(name: "Henry",msg: "Hi,Swift")
If you want to have English as readable function labels, but donβt want to change the name of the input parameter, you can add a label before the parameter names, for example,
func say(somethingBy name:String, whoIsActuallySaying msg:String) { print("\(name) say \(msg)") }
Then call it as follows
self.say(somethingBy: "Henry",whoIsActuallySaying: "Hi,Swift")
Fangming Ning Jul 14 '17 at 20:01 2017-07-14 20:01
source share