xor method

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

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

Implementation

Option<T> xor(Option<T> other) {
  if (isSome()) {
    if (other.isSome()) {
      return None;
    } else {
      return this;
    }
  }
  if (other.isSome()) {
    return other;
  }
  return None;
}