[swift-evolution] Proposal: Replace ?? by an (optional) argument to ?
kevin at sb.org
Sun Jan 31 19:36:54 CST 2016
Correction: `x` has type `((Bool) -> Void)?`.
> On Jan 31, 2016, at 5:05 PM, Kevin Ballard via swift-evolution <swift-evolution at swift.org> wrote:
> This change as proposed is impossible. The syntax `x?(false)` already has a well-defined and necessary meaning, which is optional chaining on function application. By that I mean that if `x` has the type `(Bool) -> Void` then invoking it looks exactly like `x?(false)`. You often see this in code that invokes `optional` delegate methods or optional completion blocks.
> Furthermore, I think the ?? operator is already great and does something unique enough to warrant its own syntax.
> -Kevin Ballard
>> On Jan 25, 2016, at 6:03 PM, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
>> * 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 at swift.org
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution