4 ms·
This is exactly why I like the Objective-C method call syntax. Instead of "mystery argument soup" rectangle->set(10,10,20,20,true,false) you get somethi
by jjoonathan 12y ago
This is exactly why I like the Objective-C method call syntax. Instead of "mystery argument soup"
rectangle->set(10,10,20,20,true,false)
you get something that can be understood without taking a trip to the API docs:
[rectangle setX:10 y:10 width:20 height:20 updateBSP:YES clipToParent:NO]
It's a pity they are moving away from this syntax in Swift. It's the right move -- I hear nothing but hate for it from those who don't actually use it (i.e. the people who should be Swift's target audience) -- but it's still a pity.
- Marat_Dukhan 12y agoI think C++ should use notation similar to designated initializers (that C++ adapted from C99) for names arguments, i.e. rectangle->set(.x = 10, .y = 20, .width = 20, .height = 20) Otherwise, it would be very confusing that two different syntax are used for similar purpose.
- chingjun 12y agoSwift has named arguments, and it's called "external parameter name". Here's an example taken from Apple's documentation[1]. func join(string s1: String, toString s2: String, withJoiner joiner: String) -> String { return s1 + joiner + s2 } join(string: "hello", toString: "world", withJoiner: ", ") // returns "hello, world" [1]: https://developer.apple.com/library/ios/documentation/swift/conceptual/swift_programming_language/Functions.html https://developer.apple.com/library/ios/documentation/swift/...