<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">In reviewing the proposal and looking at the statement form:<div class=""><br class=""></div><div class=""><div class=""><div class=""><div class=""><font color="#9929bd" class="">public</font> <font color="#61177c" class="">enum</font> <font color="#0056d6" class="">Trade</font> {</div><div class=""> <font color="#9929bd" class="">case</font> Buy(quantity: Double, price: Double)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> Sell(quantity: Double, price: Double)</div><div class="">}</div><div class=""><br class=""></div><div class=""><font color="#7b219f" class="">let</font> commissions = trades.<font color="#61177c" class="">map</font> {</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<font color="#9929bd" class="">let</font> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <font color="#9929bd" class="">where</font> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * commissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <span style="color: rgb(153, 41, 189);" class="">where</span> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> quantity * price * commissionRate / 100</div><div class="">}</div></div></div><br class="Apple-interchange-newline">I feel like it needs some syntax to indicate there is a return value for each case: </div><div class=""><br class=""></div><div class=""><div class=""><font color="#9929bd" class="">public</font> <font color="#61177c" class="">enum</font> <font color="#0056d6" class="">Trade</font> {</div><div class=""> <font color="#9929bd" class="">case</font> Buy(quantity: Double, price: Double)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> Sell(quantity: Double, price: Double)</div><div class="">}</div><div class=""><br class=""></div><div class=""><font color="#7b219f" class="">let</font> commissions = trades.<font color="#61177c" class="">map</font> {</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<font color="#9929bd" class="">let</font> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <font color="#9929bd" class="">where</font> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * commissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <span style="color: rgb(153, 41, 189);" class="">where</span> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <= quantity * price * commissionRate / 100</div><div class="">}</div></div><div class=""><br class=""></div><div class="">it would enforce that there is only one <= for each and check that each result is the correct type to prevent errors where multiple return values are generated but the last one is ignored, I suppose that could be a warning though. This would only be used in the “case” form where multiple statements are used. Another option but we loose conciseness is to require return for multi statement expressions, but if you are doing multi statement, then you are probably not as concerned about conciseness:</div><div class=""><br class=""></div><div class=""><div class=""><font color="#9929bd" class="">public</font> <font color="#61177c" class="">enum</font> <font color="#0056d6" class="">Trade</font> {</div><div class=""> <font color="#9929bd" class="">case</font> Buy(quantity: Double, price: Double)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> Sell(quantity: Double, price: Double)</div><div class="">}</div><div class=""><br class=""></div><div class=""><font color="#7b219f" class="">let</font> commissions = trades.<font color="#61177c" class="">map</font> {</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<font color="#9929bd" class="">let</font> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <font color="#9929bd" class="">where</font> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <font color="#9929bd" class="">return</font> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Buy(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">return</span> quantity * price * commissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price) <span style="color: rgb(153, 41, 189);" class="">where</span> quantity * price > 10000:</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> vipCommissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">return</span> quantity * price * vipCommissionRate / 100</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">case</span> .Sell(<span style="color: rgb(153, 41, 189);" class="">let</span> quantity, <span style="color: rgb(153, 41, 189);" class="">let</span> price):</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">let</span> commissionRate = <font color="#450e59" class="">calculateCommissionRate</font>(...)</div><div class=""> <span style="color: rgb(153, 41, 189);" class="">return</span> quantity * price * commissionRate / 100</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>