Did not think about that. In that case I agree that the extra keyword should be both in the constructor and on the property
And in android @Parcelize
All parameters of the primary constructor must be properties (
var ), otherwise they can not be (de)serialized
- If there is a non-property parameter, it is a compile-time error
What would you think about the following one?
owned field: Type
My idea is basically about the keyword
owned, which would mean that, since the field is owned by the class, only that’s got the right to change its value.
owned can’t be stood with, you could think about any other keyword that makes sense.
What would be the purpose of this feature? How is it different from using a var with private setter?
var field: Type private set
I was referring to a private-set field in the primary constructor of a class. Not member fields within the block of the class
data class Example(val x: Type1, var y: Type2; private set, var z: Type3)
to indicate that y is a variable with private setter?
(even the syntax highlighter like it )