xor method

Spec<T> xor(
  1. Spec<T> other
)

Combines this spec with another using XOR logic (exclusive OR).

Equivalent to using the ^ operator. Returns a new spec that is satisfied when exactly one of the two specs is satisfied, but not both and not neither. Use this for mutually exclusive conditions.

Example:

// Exactly one must be true
final exclusive = IsStudent().xor(IsWorking());
final status = IsPublished().xor(IsDraft()); // One or the other, not both

Implementation

Spec<T> xor(Spec<T> other) => _Xor(this, other);