<Idiomatic immutability when updating value on cla...
# forum
r
Idiomatic immutability when updating value on class of class Apologies if the title is confusing; I’m not sure how best to explain this in the title. Basically, I have two classes, Foo and Bar. Foo has a property of type Bar. Bar has a Set on it. data class Foo(bar: Bar) data class Bar(ints: Set) When I have an instance of Foo, and I want to add an Int to the set of Ints on bar, how do I do that in an idiomatic, immutable way that isn’t also ugly and confusing? This is what I’ve got so far: val myNewInt = 5 myFooDAO.save(foo.copy(bar =...