<div dir="ltr">Assuming Paul is correct then you require Optional to be a sequence type and you would use flatMap. I believe there has been such discussions in the past but they don't seem to have gone anywhere. Java and Scala both do what you want with their sequence types, maybe Swift will follow :).</div><div class="gmail_extra"><br><div class="gmail_quote">On 28 January 2016 at 16:30, Craig Cruden via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Yes<div><div class="h5"><br><div><blockquote type="cite"><div>On 2016-01-28, at 12:28:40, Paul Ossenbruggen <<a href="mailto:possen@gmail.com" target="_blank">possen@gmail.com</a>> wrote:</div><br><div><div style="word-wrap:break-word">Trying to see if I got this. So the type of r would be Int? at the end of this? And if n were nil then r would be nil? Otherwise it r is 10?<div><br></div><div><div><br></div><div><br><div><blockquote type="cite"><div>On Jan 27, 2016, at 9:19 PM, Craig Cruden via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div style="word-wrap:break-word">Swift currently encourages a lot of conditional code - especially when it comes to optionals. In most cases when you are computing etc. on an Optional you would expect that you would want an optional result and things to be able to use optionals. <div><br></div><div>In another language I generally just `map` one optional to another - which may not be the most readable code to some not use to optionals. </div><div><br></div><div>I was wondering if maybe an expression is not available that it would rewrite the syntax to map from one to another value. </div><div><br></div><div>So things like:</div><div><br></div><div>let n : Int? = 5</div><div><br></div><div>let r = n + 5</div><div><br></div><div>would actually compile as </div><div><br></div><div>let r = n.map <span style="font-family:Menlo;font-size:11px">{$0 + </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">5</span><span style="font-family:Menlo;font-size:11px">}</span></div></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"> -- Howard.<br></div>
</div>