xor method

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

Returns Some if exactly one of self, other is Some, otherwise returns None.

Implementation

@pragma("vm:prefer-inline")
Option<T> xor(Option<T> other) {
  if (v == null) {
    if (other.isSome()) {
      return other;
    }
    return None;
  } else {
    if (other.isSome()) {
      return None;
    }
    return Some(v!);
  }
}