[swift-evolution] [pitch] adding toggle to Bool

Erica Sadun erica at ericasadun.com
Sat Jan 13 15:54:29 CST 2018


On Jan 13, 2018, at 12:06 PM, Karl Wagner via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On 12. Jan 2018, at 20:54, Alejandro Martinez via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> I wouldn't go as far as to ask to fade out ! but in all my code I end
>> up doing == false just for readability. That ! knows who to hide
>> himself too well :P
>> 
> 
> Yeah so do I. ! is a very narrow character and totally changes the meaning of the logic.
> 
> 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.
> 
> - Karl

>> Nate:
>> I would have gone straight to a proposal, but I think we can do some
>> bikeshedding about the name of `toggle`?
>> 
>> Another verb that could work is `invert`.

I prefer `toggle()`/`toggled()` to `invert()`/`inverted()`.  I could go on about why but I'm not 100% that this extension adds sufficient utility that it passes the inclusion bar. I would vote against adding them under either name.

I feel more strongly about `.isTrue`/`.isFalse`. I don't think we need them.

-- E


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180113/20ebb741/attachment.html>


More information about the swift-evolution mailing list