<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"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></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: 'all', 'any', 'some', 'none' methods instead of just 'contains(where:)'.<div>Plus, we could add 'unless' alongside 'guard'. But these features were postponed to Stage 2.</div></div></div></div>