3 ms·
No it’s not. If you have multiple parameters Obj-C is much longer and ugly.
by jbluepolarbear 5y ago
No it’s not. If you have multiple parameters Obj-C is much longer and ugly.
- iainmerrick 5y agoWhere are you getting this from? Swift’s mandatory named parameters come from Objective-C. For the most part only the bracket placement is different.
- jbluepolarbear 5y agoSwift supports default and objc doesn’t. This makes calls smaller. Swift also has argument hiding with the underscore before the parameter. Swift also ask variable arguments. Hiding named parameters and variable arguments make calls much smaller. My point stands.
- Apocryphon 5y agoThat's not really "much" longer. And in some cases the brevity saved could really increase obfuscation and confusion.
- jbluepolarbear 5y agoYes it is; especially, if there’s long parameter names. And I disagree with the obfuscation and confusion, but that’s a discussion on Swifts goal of self documentation not code length.
- stefanfisk 5y agoyou can define ObjC method parameters with empty selector names if you want. 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]; }
- zionic 5y agoMandatory names parameters? 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.