Danilo Herrera
02/21/2019, 6:52 PMDanilo Herrera
02/21/2019, 6:58 PMRuckus
02/21/2019, 7:02 PMonly meant to be a data classWhy? what's significant about a data class? Ultimately they're just normal classes with some functions generated for you, and even those functions can be overridden, so being a data class doesn't really get you anything.
Danilo Herrera
02/21/2019, 7:07 PMcopy method.Dominaezzz
02/21/2019, 7:10 PMinterface Copy<T> { fun copy(): T }. Not sure how nicely it'll play with data classes though.streetsofboston
02/21/2019, 7:20 PMinterface Copy, the copy function of a data class has an unknown signature, except for its name and return typeDanilo Herrera
02/21/2019, 7:23 PMinterface Cloneable<T> {
fun clone(): T
}
which in turn makes the data classes have this implementation:
data class User(val id: String) : Cloneable<User> {
fun clone() = copy()
}karelpeeters
02/21/2019, 8:00 PMinterface Cloneable<T: Clonable<T>>