Re: Swift definition of "_"

Bernie Maier

On Tue, 17 Sep 2019, at 8:28 PM, Dave wrote:
Hi All,

In a definition like this:

func NSLocationInRange(_ loc: Int, _ range: NSRange) -> Bool

What does the “_” by itself mean? I can’t seem to find anywhere in the
documentation where this is mentioned? If its in there somewhere I’d
appreciate a pointer to it.
It means the corresponding function argument does not have a parameter label when **calling** the function. So you would call via something like:

NSLocationInRange(42, someRange)
This is documented in the Swift Language Guide (

Omitting Argument Labels
If you don’t want an argument label for a parameter, write an underscore (_) instead of an explicit argument label for that parameter.

func someFunction(_ firstParameterName: Int, secondParameterName: Int) {
// In the function body, firstParameterName and secondParameterName
// refer to the argument values for the first and second parameters.
someFunction(1, secondParameterName: 2)
If a parameter has an argument label, the argument must be labeled when you call the function.

Join to automatically receive all group messages.