<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=""><font face="Courier" style="font-size: 14px;" class="">If you would like something better than "== false" I suggest adding computed properties&nbsp;</font><span style="font-family: Courier; font-size: 14px;" class="">'isTrue' and 'isFalse' </span><font face="Courier" style="font-size: 14px;" class="">to Boolean.</font><div class=""><font face="Courier" class=""><span style="font-size: 14px;" class=""><br class=""></span></font></div><div class=""><font face="Courier" class=""><span style="font-size: 14px;" class=""><br class=""></span></font><div><blockquote type="cite" class=""><div class="">On Jan 13, 2018, at 11:06 AM, Karl Wagner 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=""><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">On 12. Jan 2018, at 20:54, Alejandro Martinez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">I wouldn't go as far as to ask to fade out ! but in all my code I end<br class="">up doing == false just for readability. That ! knows who to hide<br class="">himself too well :P<br class=""><br class=""></blockquote><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Yeah so do I. ! is a very narrow character and totally changes the meaning of the logic.</span><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">That said, I can’t come up with a clearer name than “== false”. inverted() isn’t helpful. toggle() on a mutable Bool is good, though.</span><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">- Karl</span><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">On Fri, Jan 12, 2018 at 10:13 AM, Adrian Zubarev via swift-evolution<br class="">&lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><blockquote type="cite" class="">I’m not sure if this would be considered or not, but I would like if the<br class="">negation operator `!` would fade out.<br class=""><br class="">If this is ever going to a review then I’d suggest that we add a pair of<br class="">functions, one mutating and the other non-mutating.<br class=""><br class="">extension Bool {<br class="">mutating func invert() {<br class="">&nbsp;&nbsp;self = !self<br class="">}<br class=""><br class="">func inverted() {<br class="">&nbsp;&nbsp;return !self<br class="">}<br class="">}<br class=""><br class="">I’d rather use `inverted` instead of `!` because of the readability this<br class="">function provides.<br class=""><br class="">if !items.contains(item) { ... }<br class=""><br class="">if items.contains(item).inverted() { ... }<br class=""><br class="">——<br class=""><br class="">I personally have some other extensions like:<br class=""><br class="">extension Bool {<br class="">@discardableResult<br class="">func whenTrue&lt;T&gt;(execute closure: () throws -&gt; T) rethrows -&gt; T? {<br class="">&nbsp;&nbsp;if self { return try closure() }<br class="">&nbsp;&nbsp;return nil<br class="">}<br class=""><br class="">@discardableResult<br class="">func whenFalse&lt;T&gt;(execute closure: () throws -&gt; T) rethrows -&gt; T? {<br class="">&nbsp;&nbsp;if !self { return try closure() }<br class="">&nbsp;&nbsp;return nil<br class="">}<br class="">}<br class=""><br class="">But this is more a personal preference.<br class=""><br class="">——<br class=""><br class="">That said, if the community is fine with the `invert/inverted` pair then I’d<br class="">say go for it ;)<br class=""><br class="">Am 12. Januar 2018 um 09:14:22, Nate Cook via swift-evolution<br class="">(<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>) schrieb:<br class=""><br class=""><br class="">On Jan 12, 2018, at 12:15 AM, Chris Eidhof via swift-evolution<br class="">&lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">Hey SE!<br class=""><br class="">When we have a bunch of nested structs:<br class=""><br class="">&nbsp;&nbsp;struct Sample {<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var bar: Bar<br class="">&nbsp;&nbsp;}<br class=""><br class="">&nbsp;&nbsp;struct Bar {<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var show: Bool<br class="">&nbsp;&nbsp;}<br class=""><br class="">&nbsp;&nbsp;var foo = Sample(bar: Bar(show: false))<br class=""><br class="">It can be repetitive to toggle a deeply nested boolean:<br class=""><br class="">&nbsp;&nbsp;foo.bar.show = !foo.bar.show // duplication<br class=""><br class="">I sometimes add a `toggle` extension on `Bool`<br class=""><br class="">&nbsp;&nbsp;extension Bool {<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mutating func toggle() {<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self = !self<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br class="">&nbsp;&nbsp;}<br class=""><br class="">This allows you to write the same code without duplication, and makes the<br class="">intent clearer:<br class=""><br class="">&nbsp;&nbsp;foo.bar.show.toggle()<br class=""><br class=""><br class="">I like it!<br class=""><br class="">In other languages, I don't think the `toggle` would make as much sense, but<br class="">the mutable self makes this very useful.<br class=""><br class="">After I posted it on Twitter, it turns out I'm not the only one:<br class=""><a href="https://twitter.com/PublicExtension/status/730434956376346624" class="">https://twitter.com/PublicExtension/status/730434956376346624</a><br class=""><br class="">I would have gone straight to a proposal, but I think we can do some<br class="">bikeshedding about the name of `toggle`?<br class=""><br class=""><br class="">Another verb that could work is `invert`.<br class=""><br class="">The `!` operator that does this is the negation operator, but I think<br class="">`negate` could sound to some like "make this false" rather than toggling.<br class=""><br class="">Nate<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class="">swift-evolution@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""><br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class="">swift-evolution@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""><br class=""></blockquote><br class=""><br class=""><br class="">--<span class="Apple-converted-space">&nbsp;</span><br class="">Alejandro Martinez<br class=""><a href="http://alejandromp.com" class="">http://alejandromp.com</a><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class="">swift-evolution@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Courier; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></body></html>