I have the following code:
class ViewHolder(itemView: View, val ui: ViewUI)
I don't want that the field ui have a getter, but kotlin is generating it by default since it is a val defined in the constructor.
In the properties and fields document I found that I can generate a private getter with the following code
var setterVisibility: String = "abc"
private set
But I can't find a way to do this in the constructor definition
You can make the entire property private in the constructor, that way it will only be accessible inside the class:
class ViewHolder(itemView: View, private val ui: ViewUI)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With