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

Sébastien Blondiau sebastien.blondiau at me.com
Mon Mar 7 15:29:59 CST 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160307/10269745/attachment.html>


More information about the swift-evolution mailing list