nulldev
10/02/2017, 9:02 PMdata class WTF(var name: String
set(value) {
println("This doesn't work 😞")
}
)
Ruckus
10/02/2017, 9:13 PMdata
modifier still applies.nulldev
10/02/2017, 9:32 PMdata class
just auto-implement equals
, hashCode
, toString
and a copy function?
This particular class is in an API. I have to check if the values provided to the setter are valid and throw an exception if they are not.Ruckus
10/02/2017, 9:36 PMWe frequently create classes whose main purpose is to hold data. In such a class some standard functionality and utility functions are often mechanically derivable from the data. In Kotlin, this is called a data class ...(see https://kotlinlang.org/docs/reference/data-classes.html) If you are changing how the data is set or retrieved, you're probably breaking the "mechanically derivable standard functionality" point of data classes.
gps
10/03/2017, 5:32 AMgjesse
10/03/2017, 5:26 PMgjesse
10/03/2017, 5:30 PM