[swift-evolution] Brainstorming: Optional sugar inferred map

Thorsten Seitz tseitz42 at icloud.com
Tue Feb 16 00:32:31 CST 2016


> Am 16.02.2016 um 05:52 schrieb Paul Ossenbruggen via swift-evolution <swift-evolution at swift.org>:
> 
> Currently it is possible to do this: 
> 
> a ?? doSomething(59)
> 
> it is not a huge stretch to allow the result of the left hand optional expression on the right hand side:
> 
> 	    a ?? doSomething($$)

Actually it *is* a huge stretch because it is just the opposite!
The second version is just `map` written with an operator where the rhs is only called for the case that a value is present, i.e. non-nil.
The first version covers the opposite case where the value is absent, i.e. is nil. 

-Thorsten 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160216/8c18a2f0/attachment.html>


More information about the swift-evolution mailing list