Skip to content
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

Add ^^ as a logical boolean XOR expression #530

Closed
DartBot opened this issue Nov 19, 2011 · 5 comments
Closed

Add ^^ as a logical boolean XOR expression #530

DartBot opened this issue Nov 19, 2011 · 5 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Nov 19, 2011

This issue was originally filed by [email protected]


The binary expressions include &, | and ^ but the logical boolean expressions only have && and ||. Adding ^^ for XOR will be consistent (and it will make my code shorter).

@rakudrama
Copy link
Member

&& and || are short-circuit because 'and' and 'or' 'stick' at false and true respectively.
^^ has no such property - both operands must always be evaluated.
This makes ^^ just a synonym for !=


Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Dec 14, 2011

Set owner to @gbracha.
Added Accepted label.

@anders-sandholm
Copy link
Contributor

We suggest using the mostly equivalent !=


Added WontFix label.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels May 8, 2012
@kevmoo kevmoo added closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug and removed resolution-wont_fix labels Mar 1, 2016
@ThinkDigitalSoftware
Copy link

&& and || are short-circuit because 'and' and 'or' 'stick' at false and true respectively.
^^ has no such property - both operands must always be evaluated.
This makes ^^ just a synonym for !=

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

oh! Thank you!!! that's what I need!!!! Trying to make sure both of my operands are not the same

@lrhn
Copy link
Member

lrhn commented Nov 30, 2018

For the record, since Dart 2.1, the bool class has had non-short-circuit operators &, | and ^.

They can be used where you want both sides to be evaluated, and, especially for ^, they can be used in assignments: bool parity = false; while (something) parity ^= checkSomething();.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants