Overloading equivalence (==) operator for custom class in Swift
Is it possible to overload equivalence (==) operator for a custom class inside that custom class. However I know that it is possible to have this operator overloaded outside class scope. Appreciate any sample code. Thanks in advance. Add global functions. For example: class CustomClass { var id = "my id" } func ==(lhs: CustomClass, rhs: CustomClass) -> Bool { return lhs == rhs } func !=(lhs: CustomClass, rhs: CustomClass) -> Bool { return !(lhs == rhs) } To conform Equatable protocol in Swift 2 class CustomClass: Equatable { var id = "my id" } func ==(left: CustomClass, right: CustomClass) ->