What is External Parameter Names in SWIFT?

0 votes
57 views
asked Mar 4, 2015 in Swift by admin (8,115 points)
Hi All

  What is External Parameter Names in SWIFT?

1 Answer

0 votes
answered Mar 4, 2015 by codeg (2,600 points)

Hi 

func join(string s1: String, toString s2: String, withJoiner joiner: String) -> String {

return s1 + joiner + s2

}

In this version of the join function, the first parameter has an external name of string and a local name of s1; the second parameter has an external name of toString and a local name of s2; and the third parameter has an external name of withJoiner and a local name of joiner.

You can now use these external parameter names to call the function unambiguously:

  • join(string: "hello", toString: "world", withJoiner: ", ")
  • // returns "hello, world"
...