External Parameter Names

Usually you create a function with parameters and just pass them. However, external parameters must be written. Part of what makes Objective-C such a powerful language is its descriptiveness. Swift engineers wanted to also include that descriptiveness, and this is why the language includes external parameter names. External parameters allow for extra clarity. The syntax for including external parameter names in a function looks like this:

func someFunction(externalName internalName: parameterType) -> returnType {  // Code goes here}

The keyword func is followed by the name of the function. In the parameters of the function, there’s an extra name for the parameters. The whole parameter is ...

Get Learning Swift™ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.