6.4. More on function parameters
Parameter labels
//function definition...
func navigate(with vehicle:String, from source:String, to destination:String) -> String{
return "The user will use a \(vehicle) to travel from \(source) to \(destination)."
}
//calling the function
print(navigate(with: "car", from: "Boston", to: "NYC"))The user will use a car to travel from Boston to NYC.Omitting parameter labels
//function definition...
func printHello(_ name:String){
print("Hello \(name)!")
}
//Calling the function...
printHello("Sakib")Default parameters
Why and where do we use internal and external names in Swift functions?
Scenarios where internal and external names are useful
Last updated