I want to choose named tuples over case classes in some scenarios where they feel more natural and involve less boilerplate, but I’ve found that they bizarrely do not ship with a .copy
method for easily modifying them like case classes do.
type Foo = (a: Int, b: Int)
val foo: Foo = (a = 1, b = 0)
val modified = foo.copy(a = foo.a+1)
// value copy is not a member of Foo
I don’t see a reason why this method doesn’t exist for named tuples, and the fact that it doesn’t while it does for case classes acts effectively as a deterrent for me in ever choosing named tuples as the abstraction if I care about convenience – which is not the sort of thing that should factor in to my decision making process when choosing the right abstractions.
Can we add a pre-generated copy
method for named tuples, so they are as convenient to use as case classes?