Reputation: 318
The current version of Dart Editor is showing the bitwise XOR operator as not defined for class bool
I don't see it defined in num.dart
either.
Ex:
bool x = a ^ b;
The editor shows the "Caret" as not defined.
Update:
Dart's api spec only allows bitwise XOR on integers. I fixed my code to properly work with bool
s.
Upvotes: 5
Views: 7131
Reputation: 2273
You can use the XOR operator on booleans since Dart version 2.1
[...] 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();
.
Taken from the corresponding Github issue.
See the dart documentation for XOR here.
Upvotes: 4
Reputation: 42383
(Copied from the question, so that this appears as answered...)
Dart's spec only allows bitwise XOR on integers.
Upvotes: 2