That&#39;d be the point. If doSomething were not optional, when &quot;n?&quot; appears in it, it becomes optional (it&#39;s basically optional chaining, but for function calls and other expressions instead of just dot-notation).<br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 28, 2016 at 8:38 PM Craig Cruden &lt;<a href="mailto:ccruden@novafore.com">ccruden@novafore.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><blockquote type="cite"><div dir="ltr"><div>    manager.doSomething(data: data, count: n?)</div></div></blockquote><div><br></div>What if the return value of doSomething is not an optional?  Expressions are easy — but there might be some conflicts with this one.</div><div style="word-wrap:break-word"><div><br><div><div dir="ltr"><div><br></div></div></div><div><blockquote type="cite"><div>On 2016-01-28, at 14:34:58, Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div dir="ltr">I&#39;ve wanted this sort of thing a lot. It would also work for other functions, such as<div><br></div><div>    manager.doSomething(data: data, count: n?)</div><div><br></div><div>which is equivalent to</div><div><br></div><div>    n.map { manager.doSomething(data: data, count: $0) }</div><div class="gmail_extra"><br></div><div class="gmail_extra">It might be hard to see exactly which operator/function applications such a thing applies to, if used in the context of a complex expression.</div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Wed, Jan 27, 2016 at 9:50 PM, Paul Ossenbruggen via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</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">Maybe something like this?<div><br></div><div><span><div><div style="margin:0px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">let</span> n : <span style="color:#703daa">Int</span>? = <span style="color:#272ad8">5</span></div><div><span style="color:#272ad8"><br></span></div></div></span><div><div style="margin:0px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">let</span> r = <span style="color:#4f8187">n</span>? + <span style="color:#272ad8">5</span></div><div><span style="color:#272ad8"><br></span></div><div><span style="color:#272ad8"><br></span></div></div><div><div><div><blockquote type="cite"><div>On Jan 27, 2016, at 9:46 PM, Thorsten Seitz &lt;<a href="mailto:tseitz42@icloud.com" target="_blank">tseitz42@icloud.com</a>&gt; wrote:</div><br><div><div dir="auto"><div></div><div>Too much hidden magic IMO. This would mean loosing the benefits of optionals, i.e. making explicit where optional cases occur and that handling the missing case has to be considered. </div><div><br></div><div>-Thorsten </div><div><br>Am 28.01.2016 um 06:30 schrieb Craig Cruden via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;:<br><br></div><blockquote type="cite"><div>Yes<br><div><blockquote type="cite"><div>On 2016-01-28, at 12:28:40, Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" target="_blank">possen@gmail.com</a>&gt; 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 &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; 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></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></div></blockquote></div><br></div></div></div></div><br>_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></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></blockquote></div>