<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=""><div class="">Good point. In such a case it would be more rational to have “not" as func not(value Bool) -&gt; Bool { … } . But I am not a fun of such solution either.</div><div class="">You see, in swift, there is a lot of code that looks like:</div><div class=""><br class=""></div><div class="">let newValue = rawValue</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>.transformA(arg1) { ... }</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>.transformB(arg2) { ... }</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>.transformC(arg3) { ... }</div><div class=""><br class=""></div><div class="">It looks as a pipeline of transformations to me and I consider negation as one of those transformations. On the other hand negation operator totally breaks this pipeline. I personally prefer a bit longer list of transformations rather than list of transformations and negation operator as prefix to the list.</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">21 трав. 2016 р. о 17:59 Charlie Monroe &lt;<a href="mailto:charlie@charliemonroe.net" class="">charlie@charliemonroe.net</a>&gt; написав(ла):</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=""><div class="">This would make sense as an operator (or actually it would have to be a keywod):</div><div class=""><br class=""></div><div class="">return not self.lanes[...].contains(.Gap)</div><div class=""><br class=""></div><div class="">Or if you don't mind having { } around the expression it could be defined as a function:</div><div class=""><br class=""></div><div class="">func not(@noescape block: (Void) -&gt; Bool) rethrows -&gt; Bool { return !block() }</div><div class=""><br class=""></div><div class="">Then you can have</div><div class=""><br class=""></div><div class="">return not { self.lanes[...].contains(.Gap) }</div><div class=""><br class=""></div><div class="">But I am personally not a fan of this.</div><div class=""><br class=""></div><div class="">Charlie</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 21, 2016, at 4:50 PM, Антон Миронов via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I found negation operator (!) the least detectable among the code. So I’ve decided to add property “not” to BooleanType (Swift 2.2) or Boolean on 3.0 with extension:<div class=""><br class=""></div><div class="">extension BooleanType {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var not: Bool { return !self.boolValue }</div><div class="">}<br class=""><div class=""><div class=""><br class=""></div><div class="">This is code with negation operator:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return !self.lanes[position.y][currentLaneRange].contains(.Gap)</div></div></div><div class=""><div class=""><div class=""><br class=""></div><div class="">As I sad before negation operation is hard to spot. Moreover at first it looks like I’m trying to negate self for some reason.</div><div class=""><br class=""></div><div class="">This is code with “not” property:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>return self.lanes[position.y][currentLaneRange].contains(.Gap).not</div></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><br class=""></div></blockquote><div class=""><div class="">Now it is easy to spot the statement I am actually getting negation of.</div><div class="">On my experience negation operator can occasionally be missed while reading code. This happens less often with “not” property. So I’m proposing to add this property to standard library and prefer it in most cases.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Anton Mironov</div></div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>