<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Don’t we already have the following?</div><div class=""><br class=""></div><div class="">let message:String = (x % 2) ? “x is even” : “x is odd"</div><div class="">&nbsp;</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 5, 2015, at 7:02 AM, J. Cheyo Jimenez &lt;<a href="mailto:cheyo@masters3d.com" class="">cheyo@masters3d.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class="">Hi Sergey,</span></font><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""><br class=""></span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class="">Are you thinking on writing the formal proposal for the if expression?&nbsp;</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""><br class=""></span></font></div><div class=""><font size="2" style="background-color:rgba(255,255,255,0)" class=""><a href="https://lists.swift.org/pipermail/swift-evolution/2015-December/000165.html" target="_blank" style="background-color:rgba(255,255,255,0)" class="">https://lists.swift.org/pipermail/swift-evolution/2015-December/000165.html</a></font></div><div class=""><br class=""></div><br class="">On Friday, December 4, 2015, Sergey Shulepov &lt;<a href="mailto:s.pepyakin@gmail.com" class="">s.pepyakin@gmail.com</a>&gt; wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello.<br class="">
<br class="">
It would be cool if control flow statements like "switch", "if" can be used as expressions, such as in languages like Scala, Rust and Kotlin,<br class="">
<br class="">
var message: String<br class="">
if x % 2 == 0 {<br class="">
&nbsp;message = "x is even"<br class="">
} else {<br class="">
&nbsp;message = "x is odd"<br class="">
}<br class="">
<br class="">
you can write:<br class="">
<br class="">
let message: String = if x % 2 == 0 { "x is even" } else { "x is odd" }<br class="">
<br class="">
I'm not into any kind of compiler development, and don't know is it feasible to introduce such change at the moment, but at least, I would like to hear why not.<br class="">
Thanks!<br class="">
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-evolution@swift.org')" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote>