Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there a parse-time reason that they required the "_" syntax, rather than simply:

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


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: