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

Andrew Bennett cacoyi at gmail.com
Mon Jan 25 21:05:22 CST 2016


I agree with Rob, also I prefer it without excessive brackets, brackets
tend to get mismatched because you have to go hunting for the start or end
of the expression:

    a ?? b ?? c ? d

versus:

    a?(b?(c?(d))))

I think it makes chaining cleaner and clearer.

Granted the first expression is longer, but this isn't true with styles
that require whitespace inside the brackets. Did you notice that each
expression had a mistake?


On Tue, Jan 26, 2016 at 1:52 PM, Rob Mayoff via swift-evolution <
swift-evolution at swift.org> wrote:

> `x?(false)` already has a meaning. If `x` is of type `Optional<(Bool) ->
> ()>`, then `x?(false)` means “if x is None, do nothing; if x is Some(f),
> call f(false)”.
>
> I don't think the end is "the most important position", and I don't think
> the default value is necessarily "the least important part of the
> expression".
>
> I like the existing ?? operator more than this idea.
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160126/056e764c/attachment.html>


More information about the swift-evolution mailing list