[swift-evolution] Proposal: Extend Optional Chaining to Function, Initializer, and Subscript Parameters

Garth Snyder garth at garthsnyder.com
Mon Jul 18 15:04:46 CDT 2016


> Liam: ...my proposal has been marked as out of scope for swift 3.0, so we'll have to wait a month or so to bring this back up again. 


That seems reasonable, but I _would_ like to see this come up for discussion.

IMHO, cases such as

let token = authorize(user?, password?, operation?)

are a lot more compelling than any example involving a single optional. As pointed out, a single optional is pretty easy to deal with in various ways. But checking multiple values gets clumsy:

var token: AuthToken?
if let user = user, password = password, operation = operation {
    token = authorize(user, password, operation)
}

It bothers me that the result has to be declared separately and then reset. Nested maps are even worse.

Garth

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160718/a7fa31ef/attachment.html>


More information about the swift-evolution mailing list