A field can have 5 different Strings values. Lets ...
# getting-started
d
A field can have 5 different Strings values. Lets say: “APPLE”, “ORANGE”, “PEAR”, “BANANA”, “PEACH”. What is the best way in Kotlin to define such a variable type?
🧵 1
r
Enum values have
toString()
👍 1
o
Or the
name
property. And beware of obfuscators such as ProGuard or R8 - you must instruct them to keep the enum, else their name will get mangled
You can also have the string as a property of the enum constant, therefore you could let it get obfuscated and instead reference the string property for display purposes, not worrying about keep rules
t
@okarm I didn't suspect that ! Does this mean that it is kinda dangerous to use enums names in Room entities, as the name could be mangled differently between builds ?
o
@tseisel Poorly worded by me - I meant in the context of using
toString
for display purposes.