by iainmerrick · 5y ago · 0 comments
Swift’s mandatory named parameters come from Objective-C. For the most part only the bracket placement is different.
You have been able to provide anonymous arguments since I first started playing with Swift in 2.0. The function just has to define it that way.
This for example is perfectly legal ObjC, callable as [foo gimmeAString:10 :"hey "].
- (NSString*)gimmeAString:(NSUInteger)count :(NSString*)piece {
return [@"" stringByPaddingToLength:count withString:piece startingAtIndex:0];
}