Function Parameter Names don't behave according to documentation

According to the manual:

Function Parameter Names

  • Creating a custom progress bar with images
  • Fabric release XCode 6.3 codesign xcode-select
  • How do you alloc/dealloc unsafe pointers in Swift?
  • NSData to NSString with JSON response
  • Cocoa webview UserAgent “webkit-legacy” issue
  • Swift app crashes on real device but works on simulator
  • These parameter names are only used within the body of the function itself, and cannot be used when calling the function. These kinds of parameter names are known as local parameter names, because they are only available for use within the function’s body.

        join("hello", "world", ", ")
    func join(s1: String, s2: String, joiner: String) -> String {
        return s1 + joiner + s2

    But the code doesn’t compile:

    error: missing argument labels ‘s2:joiner:’ in call
    join(“hello”, “world”, “, “)
    s2: joiner:

    Only when I try with one parameter, it becomes optional

    func join(s1: String) -> String {
        return s1

    Even more annoying, it’s not even permissible to use the first one at all:

        join(s1: "hello")

    extraneous argument label ‘s1:’ in call
    join(s1: “hello”)

    Did I miss anything while reading the documentation covering functions?

    2 Solutions Collect From Internet About “Function Parameter Names don't behave according to documentation”

    The behavior is different between functions and methods.

    For a method, the default behavior is to use the local name as the external name for all arguments after the first.

    You can think of methods defaulting to:

    func method(_ arg1: AnyObject?, #arg2: AnyObject?, #arg3: AnyObject?) {

    You can always explicitly state how you want to handle arguments

    func join(_ s1: String, _ s2: String, _ joiner: String) -> String {
        return s1 + joiner + s2

    The Swift Programming Language | Language Guide | Methods

    Specifically, Swift gives the first parameter name in a method a local parameter name by default, and gives the second and subsequent parameter names both local and external parameter names by default. This convention matches the typical naming and calling convention you will be familiar with from writing Objective-C methods, and makes for expressive method calls without the need to qualify your parameter names.

    I think they did this so that the default behavior of methods would match those in objective-c, but you can control it directly by setting the external parameter name

    (note that you can use _ for the external parameter name if you don’t want callers of your function to name the argument)

    also note: it doesn’t work the same way for bare functions as it does for methods