Hacker News new | ask | show | jobs
by derefr 3312 days ago
Is there a parse-time reason that they required the "_" syntax, rather than simply:

    func greet(greeting: String, personName: String) {
        print("\(greeting), \(personName)!")
    }
2 comments

It's a side effect of labeled arguments. The caller would use the function greet as `greet(greeting: "Hello", personName: "Alice")`.
The reason is that named parameters is the default, so in your case greeting and personName are both "internal" and "external" names. "_ greeting" sets the external name to _ (aka positional) and the internal name to "greeting" instead.