Created
March 26, 2015 23:26
-
-
Save JadenGeller/8afdbaa6cf8bf30bf645 to your computer and use it in GitHub Desktop.
Swift Logical XOR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator ^^ { associativity left precedence 120 } | |
func ^^<T : BooleanType, U : BooleanType>(lhs: T, rhs: U) -> Bool { | |
return lhs.boolValue != rhs.boolValue | |
} | |
// Example | |
false ^^ false // -> false | |
false ^^ true // -> true | |
true ^^ false // -> true | |
true ^^ true // -> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//Swift 3
precedencegroup BooleanPrecedence { associativity: left }
infix operator ^^ : BooleanPrecedence
/**
Swift Logical XOR operator
*/
func ^^(lhs: Bool, rhs: Bool) -> Bool {
return lhs != rhs
}