Hey! :smile: Does Kotlin automatically use referen...
# announcements
e
Hey! 😄 Does Kotlin automatically use referential equality for Enum types?
👌 1
d
If you use
==
it will result in a call to
equals
, which enums do not override. As such you get the default implementation, which is referentical equality. TLDR: Yes.
👌🏼 2
e
@diesieben07 enum overrides
equals
and uses reference equality internally. So if an equals call gets generated it's a waste of a call 😄
d
Ah, it overrides it to make it final, you are correct.
Its not a waste of a call. the JVM will optimize it away 😉
e
@diesieben07 most probably, yes. It was just to understand quickly what bytecode gets generated. But I'll check myself just to be sure