[swift-evolution] Make distinction between ?? -> T and ?? -> T?

Radosław Pietruszewski radexpl at gmail.com
Mon Mar 7 16:26:38 CST 2016


-1, never seen a real world situation where this would be confusing/problematic.

Having one operator is nice for chaining:

var value = someArray ?? someFallback ?? secondaryFallback ?? []

— Radek

> On 07 Mar 2016, at 22:29, Sébastien Blondiau via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Currently, there is only one nil coalescing operator, which may return an optional value or not, depending on the second parameter. This variability can leads to unclear line of code:
> 
> var isItOptionalOrNot = value ?? otherValue
> 
> I think there should be two distinct operators:
> 
> var certainlyOptional = value ?? otherValue
> var certainlyNotOptional = value ?! notOptionalValue
> 
> In my point of view, this differentiation brings more clarity about wether the result is an optional or not.
> 
> What's your opinion?
> 
> --
> Sébastien Blondiau
> _______________________________________________
> 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/20160307/93726bd1/attachment.html>


More information about the swift-evolution mailing list