I have a piece of code that looks like the following
abstract class ClassA(var data: String) {
}
case class ClassB (data:String) extends ClassA(data){
}
This throws me an error saying, parameter data needs override modifier. I wouldn't get this error if the ClassB was a regular class instead of a case class.
In order to make it compile while keeping the case class, I have to change the name of the mutable variable when I'm extending base class.
case class ClassB (data2:String) extends ClassA(data2){
}
Why is this the case and is there a more elegant way of handling this?