Is there a way to see how the generated `equals()`...
# multiplatform
s
Is there a way to see how the generated
equals()
of my data class actually looks like? I needed to change it to a normal class and now in Swift it does not work anymore. So I try to find out what the original generated method does different.
1
g
I use "show kotlin bytecode", and then "Decompile" to have a Java version. (Not sure it's exactly the same logic on Swift, but I presume it should.)
s
Where is "show kotlin bytecode"?
g
On MAC I use Cmd+Shift+A and then I type "show kotlin bytecode" (no idea where the menu is 😄 )
s
Thank you. 🙂
e
don't forget that to maintain invariants you should always override hashCode() whenever you override equals()
1
s
Of course. 🙂 👍
👍 1
m
It may also be a good idea to have another look at the documentation for data classes how “equals” is defined there. Not all properties of the class are considered for the equality test. Maybe that’s your issue.
1
s
As a fallback worst case if you can't get it to work in Kotlin, you can always write an extension in Swift adding Equatable conformance.
🙏 1