For the scala case class with the number of parameters (21 !!)
eg. case class Car(type: String, brand: String, door: Int ....) where type = jeep, brand = toyota, door = 4 .... etc
And there is a copy method that allows you to override using a named parameter: Car.copy(brand = Kia) where it becomes type = jeep, brand = Kia, door = 2 ... etc.
My question is, is there anyway I can provide a named parameter dynamically?
def copyCar(key: String, name: String) = { Car.copy("key" = "name") // this is something I make up and want to see if would work }
Can the scala reflection library provide help?
The reason I use the copy method is because I donβt want to repeat the 21 parameter assignments every time I create a case class that has only one or two parameters.
Thank you very much!
source share