I agree with Erica. The ?? operator is very readable IMO.
Furthermore x?(false).isEmpty looks like it would evaluate false.isEmpty when x is nil which is certainly not what is intended.
In addition it would not be clear which default should be used in case of multiple optional chainings happening, i.e. what should be the result of person?(false).address?.(true).isEmpty
-Thorsten
···
Am 26. Januar 2016 um 03:29 schrieb Erica Sadun via swift-evolution swift-evolution@swift.org:
On Jan 25, 2016, at 7:03 PM, Amir Michail via swift-evolution swift-evolution@swift.org wrote:
Examples:
- instead of x ?? false, you would have x?(false)
- instead of x?.isEmpty ?? false, you would have x?(false).isEmpty
I think this change would result in cleaner looking code.
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
Not loving this. I'm quite happy with ??-coalescing and don't see
a compelling reason it needs to be "cleaner". I find your suggested
enhancement less readable. Looks like an optional chaining across
a function.-- E
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution