Swift functions
up:: Swift ⚐
Named parameters and labels
Swift requires specifying parameter names
JavaScript Functions generally1 don’t use named parameters:
But in Swift, we have to specify the parameter name:
Using labels for parameter names
By prepending a string before the parameter name, we add a label.
Ideally, function names and parameter labels combine to make function calls similar to sentences.
Argument labels can be blank
This way Swift functions behave more like JavaScript functions.
Links
Footnotes
-
Although you can simulate it with parameter destructuring, or other hackery. ↩