best I can do is manually Bar(foo.a, foo.b) right?
# getting-started
u
best I can do is manually Bar(foo.a, foo.b) right?
h
Copy code
fun Foo.copy() = when(this) {
    is Bar -> copy()
    is Quax -> copy()
}
that'd certainly work, since
this
would be smartcast to the data classes, which themselves have a copy method already. i'm not sure if there's a less verbose way of accomplishing it, though.
u
not sure how would this work with params, okay my example doesnt show it, but Foo.copy would need to have merge of all params in the hierarchy
and then youd need to pass all of them,,idk
e
What I've done is add a method to the base class with the fields I want to override. Then each one can implement it by delegating to its copy method.