what is the best way to override a getter in data ...
# android
l
what is the best way to override a getter in data class? i came across this post https://code.luasoftware.com/tutorials/kotlin/override-getter-for-data-class/
m
First of all do I think this code is hard to read so I would rethink my options. But you know more since you have the bigger picture. If you really really need to have the code that way, put the logic into a function that handle the logic in get
Sorry for the bad English
a
I'm not sure of a good usecase to override the getter? In the given example I would think a factory function would make more sense so you can't create one with empty id
r
lol overriding a getter inside data class doesn't seem to cool lol. perhaps you need a open class or a abstract class instead