xor method

  1. @override
  2. @useResult
Option<T> xor(
  1. Option<T> other
)
override

Returns a Some if either, but not both, of this and other is a Some, or None otherwise.

Examples

// prints "None"
print(const Some(2).xor(const Some(3)));

// prints "Some(2)";
print(const Some(2).xor(const None()));

Implementation

@override
@useResult
Option<T> xor(Option<T> other) => other is None ? this : None<T>();