Copy Case Class While Changing Some Values
One of the built in features of case classes is to make a copy while changing some of its fields:
#copy(argument = new value, ...)
Example
case class Foo(bar: String, baz: String)
val foo = Foo(
bar = "bar",
baz = "baz"
)
val differentFoo = foo.copy(baz = "qux")