Where can I find a logical disjunction operator or function for Swift?

Is there a logical disjunction operator or function in Swift?

Even better, is there a logical disjunction that works with optional variables instead of boolean variables that returns an object when true, and returns nil when false?

A logical disjunction evaluates two boolean variables, and if at least one of them is true, then the return value is true. If neither variables is true, then the return value is false.

logical disjunction operator

Do you mean exclusive OR ?

There is the Bitwise XOR Operator.

But xor for logical is just !=

For logical var, I think you could build, either a func or an operator.

a xor b = a != b
func xor(a: Bool, b: Bool) -> Bool {
  return a != b
}

Get more details here, including to handle optionals: https://stackoverflow.com/questions/55478274/xor-in-swift-5

Logical disjunction that works with optional variables instead of boolean variables that returns an object when true, and returns nil when false?

Could you clarify ? The objects should be of same type: MyType?

What do you return if none is nil ?

  if a == nil && b == nil { return nil }
  if a == nil && b != nil { return b! }
  if a != nil && b == nil { return a! }
  if a != nil && b != nil { return ????? }
Where can I find a logical disjunction operator or function for Swift?
 
 
Q