An unlabeled parameter in Swift is a function, method, or initializer parameter that explicitly omits the external argument label at the call site. This is achieved by substituting the standard argument label with an underscore (Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
_) in the function signature, requiring the caller to pass the argument strictly by its positional order rather than by a named key.
In Swift, parameters possess both an argument label (used externally when invoking the function) and a parameter name (used internally within the function’s lexical scope). By default, the parameter name also serves as the argument label. To suppress the external label, the _ wildcard is placed before the internal parameter name.
Syntax
Technical Behavior
When a parameter is unlabeled, the compiler enforces positional matching at the call site. The internal parameter name remains fully accessible within the function body, but attempting to use the internal name as a label during invocation will result in a compiler error.Mixed Parameter Labeling
Functions can freely mix labeled and unlabeled parameters. The underscore only affects the specific parameter it precedes.Initializer Application
The unlabeled parameter syntax applies identically to custom initializers (init), overriding Swift’s default behavior of generating argument labels for all initialization parameters.
Master Swift with Deep Grasping Methodology!Learn More





