xor method

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

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

Implementation

Option<T> xor(Option<T> optb) {
  if (isSome && optb.isNone) {
    return Some(_someValue);
  } else if (isNone && optb.isSome) {
    return Some(optb.unwrap());
  } else {
    return None<T>();
  }
}