LastExceed
06/06/2021, 3:45 PMdata class
be open
?ephemient
06/06/2021, 3:48 PMLastExceed
06/06/2021, 3:49 PMephemient
06/06/2021, 3:54 PMKirill Grouchnikov
06/06/2021, 3:55 PMNir
06/07/2021, 1:49 AMephemient
06/07/2021, 2:30 AM.replace()
can look up the constructor of the class of the current instance, and also allows it to fail at runtime in case of post-init fieldsNir
06/07/2021, 4:07 AMRoukanken
06/07/2021, 7:24 AM.copy()
methods in subclasses, that will behave as expected
there are a few problems with it (could be probably solved by compiler?)
1. subclass can do calls in super class parameters, data class B(val a: Int, val b: Int): A(a * 2)
would make copy()
on B instances behave wierd AF (A is just open data class A(val a: Int)
) - not sure what good solution could be to this... anything that solves this will make subclassing behave differently than on normal classes (tho I guess you could just do "can't do calls in data class?")
2. copy would need to be overridable, ppls could break it (could be denied by compiler I guess)
3. subclasses would have multiple copies with diff params (but compiler is able to select proper one even now, and they all behave same)ephemient
06/07/2021, 5:07 PMRoukanken
06/07/2021, 5:20 PM