why doesn't L13 work ?
# getting-started
l
why doesn't L13 work ?
s
The
values()
method on an enum isn't actually a member of its companion object. (If it was, you wouldn't be able to define a new companion object, because there would already be one).
The docs describe it as a "synthetic method"
I think you actually can define your own
values()
method in the companion object, but it won't override the built-in one.
MyEnum.values()
will always resolve to the built-in method and will ignore the one in the companion object.
I'm guessing that KT-11968 will provide a route to resolve this oddity in the language design, which presumably stems from Java interop
l
thanks
s
No problem, sorry it's not a more satisfying explanation
This is definitely one of Kotlin's rough edges