about swift function parameter names

Steve Rohrlack
1 min readMar 16, 2016

--

The current implementation of how swift handles parameter names can be quite confusing. In some cases, providing a name for the first parameter of a function is mandatory. Some occurrences of this will result in the compiler panically raising a “Stop right there and remove that!” sign.

How come?

Natasha Muradev posted a very useful summary back in 2014 about when, why and how all of this works.

Keep in mind that the hash-syntax (stated in the article under “Hashtag It”) is not valid anymore in swift 2.

There’s already a proposal on the official swift evolution list about how to lessen the confusion about this and I’d welcome these changes to make swift parameter names more “swifty”.

Until then, I’ll be declaring external parameter names for the first argument of a function.

Happy swifting!

--

--