Hi :wave: How to implement equals method from shar...
# multiplatform
s
Hi 👋 How to implement equals method from shared code in swift? The problem is when shared code use operator “==” for 2 similar objects from swift it will return false. Shared:
Copy code
interface SharedInterface {
    val propertyA: Int
}

class SharedService() {
        fun equals(actual: SharedInterface, expected: SharedInterface){
            return actual.equals(expected)
        }
}
Swift:
Copy code
final class SharedInterfaceImpl: SharedInterface, Equatable {
   let propertyA: Int
    
static func == (lhs: SharedInterfaceImpl, rhs: SharedInterfaceImpl) -> Bool {
        lhs.propertyA == rhs.propertyA 
    }
}


// some code in iOS main class

let actual = SharedInterfaceImpl(1)
let expected = SharedInterfaceImpl(1)

print(actual == expected) // true
print(SharedService().equals(actual, expected))  //false
t
lhs.propertyA*.name* == rhs.propertyA
s
it’s mistake, sorry))