Is there any workaround to make it possible to name a Kotlin enum constant name
?
This works in Java:
public enum Dummy {
name
}
This throws Conflicting declarations: enum entry name, public final val name: String
in Kotlin
enum class Dummy {
name
}
You can't do it. Every enum member has two properties: name (string) and ordinal (int). So, there is conflict with names.
And remember. Even if you could do that you should not. Enums should be UPPERCASE (my mistake, can be also CamelCase, check first comment) and breaking this rule can be very distracting for other developers working with your code.
More information in Kotlin docs: https://kotlinlang.org/docs/reference/enum-classes.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With