Tim Oltjenbruns
02/08/2022, 1:55 AMfun <Next, Root> KProperty0<Next>.set(value: Next) = Value<Next, Root>(this, value)
Because KProperty0 is out projected, I don’t get any type checking for the value parameter. If the property is a String, I can put an Int in the value because they both inherit from Any. Is there anything I can do to make the type checking more rigid on this function? Looking for a more invariant type checking.Paul Griffith
02/08/2022, 3:46 AMTim Oltjenbruns
02/08/2022, 12:14 PMval newData = data.copy {
::order.set {
::customer.set {
::name.set {
::firstName.set("joe")
::lastName.set { it -> it.uppercase() }
}
}
}
}
// or
val patch: Patch<DataClass> = DataClass::class.patch {
::order.set {
::customer.set {
::name.set {
::firstName.set("joe")
::lastName.set { it -> it.uppercase() }
}
}
}
}
// then somewhere else
val newData = data.copyWith(patch)
Paul Griffith
02/08/2022, 9:13 PMTim Oltjenbruns
02/08/2022, 9:14 PMPaul Griffith
02/08/2022, 9:15 PMTim Oltjenbruns
02/08/2022, 9:15 PM