In many scenarios, I don't need a field to be passed in from the primary constructor, for example, a field is assigned after initialization and some steps have been taken; a field directly accesses a global variable (such as static variables, such as other persistent data).
Now I have the compromise solution is to use var
and default value
in the primary constructor, or override all serialization methods in companion object: Parceler <Model>
, both of which have disadvantages.
Why is Kotlin designed like this? Is there any better solution?