Re:Be wary of functions which take several parameters of the...
by masklinn on Friday September 27, 2019 @07:28AM
(#21090684)
Yes, however that wasn't the case before SE-0046 (Swift 3): the early iterations had much stronger ties to objective-c where the method "names" the first parameter, so the first parameter could not be labelled separately.
From Swift 3 onwards, parameters and their labelling is completely consistent.
GP is wrong in one place though (at least for swift 2, not sure for swift 1): you could label the first formal parameter explicitly, it just wouldn't be labelled by default (unlike other parameters). That is:
func f(p1:p2:)
would define
f(_:p2:)
but
func f(p1 p1:p2:)
would define
f(p1:p2:)
Also, just to make things weirder, this special-casing would not apply to initialisers.
From Swift 3 onwards, parameters and their labelling is completely consistent.
GP is wrong in one place though (at least for swift 2, not sure for swift 1): you could label the first formal parameter explicitly, it just wouldn't be labelled by default (unlike other parameters). That is:
would define but would define Also, just to make things weirder, this special-casing would not apply to initialisers.