<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-08-06 10:37 GMT+03:00 Darren Mo via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Consider code like<br>
<br>
guard !parameters.contains(where: { !validValueRange.contains($0) }) else …<br>
<br>
Oftentimes I need to write negation expressions like this. The location of the exclamation marks really bugs me when writing and reading this code. The natural English ordering would be something like<br>
<br>
“Make sure parameters does not contain an element such that validValueRange does not contain this element.”<br>
<br>
But the programming-language-imposed ordering is<br>
<br>
“Make sure NOT parameters contains an element such that NOT validValueRange contains this element.”</blockquote><div><br></div>One solution to this problem would be to add negative method versions wherever possible. For example: &#39;all&#39;, &#39;any&#39;, &#39;some&#39;, &#39;none&#39; methods instead of just &#39;contains(where:)&#39;.<div>Plus, we could add &#39;unless&#39; alongside &#39;guard&#39;. But these features were postponed to Stage 2.</div></div></div></div>