<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Everyone,<br class=""><br class="">Back in the ternary discussion, I kinda suggested the use of Guard but then I realised it’s not a replacement for ternary nor an alternative, it should not be, but may be a helpful addition to Swift.<br class=""><br class=""><font face="Menlo" class="">let a | x > 0 && x < 10 = “less than ten”<br class=""> | x > 10 && < 100 = “less than a hundred”<br class=""> | x > 100 = “more than a hundred”<br class=""> | otherwise = “probably a negative”</font><br class=""><br class="">There’s someone who said that it’s reasonable in declarations and another said that he like to explore using the bar (or pipe) character (|).<br class=""><br class="">The <font face="Menlo" class="">where</font> clause should work well with declarations. For instance, consider a function which computes the number of solutions for a quadratic equation, ax^2 + bx + c = 0<br class=""><br class=""><font face="Menlo" class="">let num | disc > 0 = 2</font><div class=""><font face="Menlo" class=""> | disc == 0 = 1<br class=""> | otherwise = 0</font></div><div class=""><font face="Menlo" class=""> where<br class=""> disc = a</font><span style="text-align: -webkit-right;" class=""><font face="Menlo" class=""><sup class="">2</sup> + b + c</font></span></div><div class=""><font face="Menlo" class=""> where</font></div><div class=""><font face="Menlo" class=""> a = 2 * 1</font></div><div class=""><font face="Menlo" class=""> b = 2 + 3</font></div><div class=""><font face="Menlo" class=""> c = 6 / 2<br class=""></font><br class="">I believe it may also help lessen the number of lines (in many cases) from using if-else-if and/or switch statements.</div><div class=""><br class="">Anyway, I just thought to start a pitch. If people will like the idea we might give a proper proposal for the boolean guard.</div><div class=""><br class=""></div><div class="">- Angelo</div><div class=""><br class=""></div></body></html>