Custom getter/setter for properties created by type params

You can use a backing property in this situation:

data class C(private val _propertyWithSetter: String) {
    val propertyWithSetter: String
        get() = _propertyWithSetter
        set(value) {
            /* execute setter logic */
            _propertyWithSetter = value
        }
}
7 Likes