0 votes
62 views
asked in Swift by (8.2k points)
Hi All

  What is External Parameter Names in SWIFT?

1 Answer

0 votes
answered by (2.6k 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"

Categories

...