Overview - Argument labels and parameter names
What is it?
Argument labels and parameter names are two ways Swift lets you name the inputs of a function. The argument label is used when calling the function, making the call clearer. The parameter name is used inside the function to refer to the input value. This separation helps make code easier to read and understand.
Why it matters
Without argument labels and parameter names, function calls can become confusing and unclear, especially when functions take multiple inputs. They solve the problem of unclear code by making function calls read like natural language. This improves code readability and reduces mistakes, making it easier to maintain and share code.
Where it fits
Before learning this, you should understand basic Swift functions and how to define and call them. After mastering argument labels and parameter names, you can learn about default parameter values and variadic parameters to write more flexible functions.