Skip to content

Bool toggle proposal #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 12, 2018
Merged

Conversation

chriseidhof
Copy link
Contributor

As the discussion seems to be short, here's the proposal.

@getaaron
Copy link
Contributor

It would be nice for toggle() to return the new value, to enable syntax like:

mySwitch.isOn = myVar.prop1.prop2.enabled.toggle()

@NachoSoto
Copy link

@getaaron that would need to be var toggled: Bool instead IMO.

@chriseidhof
Copy link
Contributor Author

chriseidhof commented Jan 17, 2018 via email

@xwu
Copy link
Contributor

xwu commented Jan 20, 2018

Some thoughts unrelated to the idea but about the proposal text itself:

Consider mentioning that prefix ! and toggled() parallel the API design for prefix - and negated().

In the alternatives section, you could also be more definitive in mentioning that renaming ! is of a kind with commonly rejected proposals to rename ?:, ||, etc.

@chriseidhof
Copy link
Contributor Author

chriseidhof commented Jan 22, 2018 via email

@@ -0,0 +1,74 @@
# Feature name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace "Feature name" with an actual title for this proposal?

@chriseidhof
Copy link
Contributor Author

@tkremenek thanks, I missed that. Fixed now.

@tkremenek
Copy link
Member

@chriseidhof FYI, I plan on kicking this review off on Monday

@airspeedswift airspeedswift merged commit 2688607 into swiftlang:master Feb 12, 2018
@krilnon
Copy link
Member

krilnon commented Feb 12, 2018

Is there an implementation PR?

@chriseidhof
Copy link
Contributor Author

There wasn't an implementation PR, but there is now: swiftlang/swift#14586

To be improved :)

johnno1962 pushed a commit to DoubleSpeak/swift-evolution that referenced this pull request Mar 18, 2018
* Bool toggle proposal

* Suggestions by @xwu

* Feature name

* Update and rename nnnn-bool-toggle.md to 0199-bool-toggle.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants