xor method
Returns whichever of the two options is present, when exactly one is.
final one = const Some<int>(1).xor(const None<int>()); // Some(1)
final both = const Some<int>(1).xor(const Some<int>(2)); // None()
Implementation
Option<T> xor(Option<T> other) {
return switch ((this, other)) {
(Some<T>(), None<T>()) => this,
(None<T>(), Some<T>()) => other,
_ => None<T>(),
};
}