Hello. I am using Object{} which has integers whic...
# android
k
Hello. I am using Object{} which has integers which i am passing around and saving those integers in db. Does this approach have any issue? OR should i use IntDef or Enum for this purpose?
g
Vote for enum
d
g
If you have limited amount of cases (like enum) why do you need inline class? Inline class make sense if you want to have special type for ids and other primitive/string types Tho I just not sure that described case related to inline classes
k
Thanks for the recommendation. I have only 3 or 4 cases. Which are 0..4. so i am setting value to each enum and using it.
z
Object[]
why?
k
Untitled
z
that's... what enums are for 🤔 (
enum class
) and then you can do
= when(enumValue) {
k
Exactly now i have changed it to enum Something like this:
👍 2
g
I wouldn't use value for this. Or use ordinal, or serialize it as name of enum
k
I understand ordinal thing. But can you please add an example why would you serialize name?
g
Easier to support backward compatibility (you can add and delete items), easier to debug DB records