<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 23, 2015 at 8:41 AM, Jonathan M Davis via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><span style="color:rgb(34,34,34)">Maybe, but the ternary operator is a lot less verbose</span></div></div></blockquote><div><br></div><div>The ternary operator becomes much harder to read the moment you have more than the simple if/else case. As it was mentioned elsewhere on this thread, you can do the following in Scala:</div><div><br></div><div>val x = if (condition_1) 1</div><div>           else if (condition_2) 2</div><div>           else if (condition_3) 3</div><div>           else 4</div><div><br></div><div>Having expressions be "built-in" extends beyond the simple if/else case, which can be emulated with the ternary operator as you said. You can assign the result of match expressions for instance, or the result of scoped blocks, .e.g.</div><div><br></div><div>val x = {</div><div>    val ys = foo()</div><div>    ys.map(...).filter(...).exists(...)</div><div>}</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><span style="color:rgb(34,34,34)">, and from some other comments in this thread, it sounds like the way they implemented it in Rust forces you to use braces for single line statements, which would be a _huge_ downside IMHO.</span></div></div></blockquote><div><br></div><div>On the other hand, Rust does not require parenthesis around if conditions:</div><div><br></div><div>let x = if some_condition { 1 } else { 2 }</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><span style="color:rgb(34,34,34)"> I'm inclined to think that it would need a use case that's a lot more compelling than if-else chains to be worth it.</span><br></div></div>
<br></blockquote><div><br></div><div>I provided examples above. </div><div><br></div><br class=""><br clear="all"><div><div class="gmail_signature">--<br>Ziad</div></div><div> </div></div><br></div></div>