[swift-evolution] Proposal: Replace ?? by an (optional) argument to ?

Kevin Ballard kevin at sb.org
Sun Jan 31 19:05:40 CST 2016

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:
> 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 at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list