These are Quick "functions", not "methods." They do not need parameter names. You can add them to the declaration for readability, but you cannot use it during a call.
On the other hand, the "methods" of the class are called and work as you expected.
If you still need named parameters when calling, try the following:
func greet(name: String, #day: String) -> String { return "Hello \(name), today is \(day)." } greet("Bob", day: "Tuesday")
This will give you the expected results.
Find this in the documentation:
However, these parameter names are used only in the body of the function itself and cannot be used when calling the function. These types of parameter names are called local parameter names, because they are only available for use in the body of functions.
A note about methods and functions: Simply put, methods belong to a class. There is no function. From the documentation:
Functions are self-contained code fragments that perform a specific task. You give the function a name that identifies what it does, and that name is used to βcallβ the function to perform its task when necessary.
Note that Swift 2.0 has nothing to do between method calls and function calls, so in Swift 2.0 your path is valid.
source share