awzurn
02/27/2019, 12:18 AMscala> case class Something[T](something: T)
defined class Something
scala> Something(1)
res0: Something[Int] = Something(1)
scala> res0.copy(something = "something")
res1: Something[String] = Something(something)
Kotlin, on the other hand, won’t compile something like this:
data class Something<T>(val value: T)
Something(1).copy("something")
I’m wondering if it was an explicit design decisions, or maybe something that just hasn’t been implemented yet?Sander Ploegsma
02/27/2019, 7:43 AMdata class Something<T>(val value: T) {
fun <U> myCopy(newValue: U) = Something(newValue)
}
Although I'm guessing that this doesn't scale well for large data classes, so I get your question.awzurn
02/27/2019, 4:05 PMSander Ploegsma
02/28/2019, 7:34 AM