<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 6, 2016, at 10:13 AM, Milos Rankovic via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Checking for divisibility is very common:<div class=""><br class=""></div><div class=""> <span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">21</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> % </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">3</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> == </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">0</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(203, 203, 203);">// true</span></div><div class=""><br class=""></div><div class="">In fact, this is such a common use of the `<span class="" style="font-family: 'Source Code Pro'; font-size: 12px;">%</span>` operator that the `<span class="" style="font-family: 'Source Code Pro'; font-size: 12px;">== </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">0</span>` side of the expression seems distracting in this use case. For quite a while now, I’ve been using a custom operator for this, which is steadily growing on me:</div><div class=""><br class=""></div><div class=""> <span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">21</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(145, 84, 15);">%==</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">3</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> </span><span class="" style="color: rgb(203, 203, 203); font-family: 'Source Code Pro'; font-size: 12px;">// true</span></div><div class=""><br class=""></div><div class="">… which also allows me to overload it for sequences:</div><div class=""><br class=""></div><div class=""> <span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">21</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(145, 84, 15);">%==</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;"> [</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">7</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;">, </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(255, 38, 0);">3</span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px;">] </span><span class="" style="font-family: 'Source Code Pro'; font-size: 12px; color: rgb(203, 203, 203);">// true</span></div><div class=""><br class=""></div><div class="">(If I’m inadvertently misusing this mailing list to share such a minor idea, please tell me off so that I can learn not to do it again!)</div><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div>While modulo checks are common, I don't think that your proposed solution (%==) enhances readability or saves typing *<b class="">to such extent</b>* that it vastly improves over the existing art:</div><div><br class=""></div><div><font face="Menlo" class="">21 % 3 == 0</font> reads easily from left to right, is quick to type, is understood across many languages.</div><div><br class=""></div><div><font face="Menlo" class="">21 %== 3 </font> saves a few spaces, is less immediately understandable (due to the visual overlap with `+=` and `-=`) and would be (as far as I'm aware of) unique to Swift.</div><div><br class=""></div><div>I applaud the thinking and creativity but I would not support the proposal.</div><div><br class=""></div><div>-- E</div><div><br class=""></div></body></html>