do data classes support deep equals (a is equal to...
# announcements
r
do data classes support deep equals (a is equal to b iff the entire object graph that starts at a and b are equal) ?
s
It will call
equals
on its parts if thats what you mean.
r
in nested structures
m
data class equals will call equals method on all of it's properties (like was said above). If the properties (and their properties...) have correctly implemented equals, then it does work as you would expect
Best would be to read docs about how equals work, how data class generates equals and try it out
r
I did verify my desired behavior with a couple of unit tests
I just had a gut feeling that equals was not “deep” since some other languages do not help you with this out of the box. With data classes it seems to be fine just out of the box