Avatar
Avatar
nanasi
@swift-5.7.3 private extension Equatable { func isEquals(_ other: any Equatable) -> Bool { guard let other = other as? Self else { return false } let op: (Self, Self) -> Bool = (==) return op(self, other) } } public func == (lhs: any Equatable, rhs: any Equatable) -> Bool { lhs.isEquals(rhs) } let i: any Equatable = 1 let d: any Equatable = 1.0 let i2: any Equatable = 1 print(i == d) print(i == i2) (edited)
false true (edited)