Reputation: 24902
Is it possible to force all parameters of a Swift method to have only internal names?
I want the syntax to be terser in a helper method and all the parameter names gets in the way.
Upvotes: 1
Views: 84
Reputation: 42325
Yep, use an _
for the external name.
From the docs:
If you do not want to provide an external name for the second or subsequent parameter of a method, override the default behavior by using an underscore character (_) as an explicit external parameter name for that parameter.
Note: You don't need an _
on the first parameter, it won't have an external name by default.
class SomeClass {
func someFunction(someString: String, _ someInt: Int, _ someDouble: Double) {
/* ... */
}
}
var c = SomeClass()
c.someFunction("foo", 1, 3.14)
Upvotes: 4