<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="">It is partially contrived (hard coded, and simplified), but reality can get quite a bit more complex. &nbsp;I tried to take a very simple understandable case and then reduce it to a very few parameters.<div class=""><br class=""></div><div class="">I still prefer the Scala syntax that uses “=&gt;” “-&gt;" instead of “:” &nbsp;or “!” between case and value - but Swift uses “:”. &nbsp;At least an IDE / editor helps readability. &nbsp;</div><div class=""><br class=""></div><div class="">I don’t like having to sprinkle “lets” all throughout the pattern matching. &nbsp; The types of Int and Double were used because it is core, I would never use Double for anything financial - just a good “BigDecimal” equivalent. &nbsp;I tried using implicit type conversion - but it playground did not like it so I just forced the issue :p</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2016-01-07, at 17:39:14, Charles Constant &lt;<a href="mailto:charles@charlesism.com" class="">charles@charlesism.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Craig, golly just looking at your example depresses me. I'm not saying it's contrived, it seems like real enough code. With the combination of our proposals, and the requirement to explicitly cast to Double... ugh, my eyes just glaze over.</div><div class=""><br class=""></div><div class="">Here's "where"...</div><div class=""><br class=""></div><div class="">let commission = trade ?</div><div class=""><span class="" style="white-space:pre">        </span>case .Buy(let quantity, let price) where Double(quantity) * price &gt; 10000:</div><div class="">&nbsp;<span class="" style="white-space:pre">                </span>Double(quantity) * price * vipCommissionRate / 100</div><div class=""><span class="" style="white-space:pre">        </span>case .Buy(let quantity, let price):</div><div class=""><span class="" style="white-space:pre">                </span>Double(quantity) * price * commissionRate / 100</div><div class=""><span class="" style="white-space:pre">        </span>case .Sell(let quantity, let price) where Double(quantity) * price &gt; 10000:</div><div class=""><span class="" style="white-space:pre">                </span>Double(quantity) * price * vipCommissionRate / 100</div><div class=""><span class="" style="white-space:pre">        </span>case .Sell(let quantity, let price):</div><div class="">&nbsp; &nbsp; <span class="" style="white-space:pre">                </span>Double(quantity) * price * commissionRate / 100</div><div class=""><br class=""></div><div class="">I also tried my favourite proposal:</div><div class=""><br class=""></div><div class="">let commission = trade ?</div><div class=""><span class="" style="white-space:pre">        </span>.Buy(let quantity, let price) !&nbsp;</div><div class=""><span class="" style="white-space:pre">                </span>Double(quantity) * price &gt; 10000 ?&nbsp;</div><div class=""><span class="" style="white-space:pre">                        </span>Double(quantity) * price * vipCommissionRate / 100 :&nbsp;</div><div class=""><span class="" style="white-space:pre">                        </span>Double(quantity) * price * commissionRate / 100 :&nbsp;</div><div class=""><span class="" style="white-space:pre">        </span>.Sell(let quantity, let price) !&nbsp;</div><div class=""><span class="" style="white-space:pre">                </span>Double(quantity) * price &gt; 10000 &nbsp;?&nbsp;</div><div class=""><span class="" style="white-space:pre">                        </span>Double(quantity) * price * vipCommissionRate / 100 :&nbsp;</div><div class=""><span class="" style="white-space:pre">                        </span>Double(quantity) * price * commissionRate / 100</div><div class=""><br class=""></div><div class="">Both of these are unreadable. I think my preferred example is slightly unreadable <b class=""><i class="">when it's indented</i></b> the way I have here, but it would be a complete and total disaster as a single line... which people tend to do with ternary expressions :( &nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div>​</div>
</div></blockquote></div><br class=""></div></div></body></html>