<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="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">The current ternary operator, for this example: <br class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">let val = p == 5 ? 10 : 40 <br class=""><br class="">Which I have always thought was hard to read but I do like the functionality it provides. That is, in one expression you can compactly get two different values based upon a condition. Swift seems to have adopted the C style ternary operators probably to not completly change everytihg. Similar to the drop of the ++ and -- operator I am proposing that there is to replace the ternary operator to improve readability but continue to provide that functionality. </font></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">Recommendation: most readable but changes rules about if-else always having braces and puts the “if” at end. </font><span class="" style="font-family: Menlo;">It is only a little bit longer than the original. </span><font face="Menlo" class="">I think it is clearer to have the conditional at the end so the assignment part is where the variable is assigned. This also does not introduce new keywords or operators. </font></div><div class=""><span class="" style="font-family: Menlo;"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">let </font><span class="" style="font-family: Menlo;">val</span><font face="Menlo" class=""> = 10 else 40 if p == 5</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class=""><br class="">In looking at the Nil-Coalescing operator there is a similar idea but it is really not the same. In that the left hand side of the ?? operator returns itself when non nil, and the behavior of the ternary operator is different. It is also harder to read. <br class=""><br class="">let </font><span class="" style="font-family: Menlo;">val</span><font face="Menlo" class=""> = 10 ?? 40 if p = 5<br class=""><br class="">I also considered a bunch of other possibilities like using “where" or “when" instead of “if”, the python of putting conditional in the middle or the ruby style of “if" returning a value but did not like those. </font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">// python style</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">let val = 10 if p == 5 else 40 </font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">// ruby style</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="">let val = if p == 5 then 10 else 40 </font></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class=""><br class=""></font></div></body></html>