Hi, In the case of <DefaultButtonElevation> class,...
# compose
j
Hi, In the case of DefaultButtonElevation class, since equals is not overridden, false is returned even if two same instances are compared. But the DefaultButtonElevation class has @Stable annotation. why? According to the official documentation, stable should always return true when comparing the same two instances, so I think that equals needs to be overridden in order for DefaultButtonElevation to be stable.
👀 1
a
The result of equals for two instances will forever be the same for the same two instances.
This just means the equality shouldn't change. Two instances of
DefaultButtonElevation
class are unequal from the beginning, and will never become equal, so they are not breaking this .
j
Aha, I misunderstood that sentence. thank you!
Then, why did the DefaultButtonColors class override equals and hashCode?
a
Generally for immutable classes it'd be better to override them but not doing so won't be a problem.
j
Thank you so much for your kind reply!