2 ms·
The first argument can be named just fine. func fn1(myLabel1 myParam1: int, myLabel2 myParam2: int) { } fn1(myLabel1: 123, myLabel2: 456) fun
by ww520 7y ago
The first argument can be named just fine.
func fn1(myLabel1 myParam1: int, myLabel2 myParam2: int) {
}
fn1(myLabel1: 123, myLabel2: 456)
func fn2(_ myParam1Omitted: int, myLabel2 myParam2: int) {
}
fn2(123, myParam2: 456)
- masklinn 7y agoYes, 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.