Is there a way to extend a case class without constantly picking up new vals along the way?
For example this doesn’t work:
case class Edge(a: Strl, b: Strl)
case class EdgeQA(a: Strl, b: Strl, right: Int, asked: Int) extends Edge(a, b)
"a" conflicts with "a", so I’m forced to rename to a1. But I don’t want all kinds of extra public copies of “a” so I made it private.
case class Edge(a: Strl, b: Strl)
case class EdgeQA(private val a1: Strl, private val b1: Strl, right: Int, asked: Int) extends Edge(a, b)
This just doesn’t seem clean to me… Am I missing something?
As the previous commenter mentioned: case class extension should be avoided but you could convert your Edge class into a trait.
If you want to avoid the private statements you can also mark the variables as override
Don’t forget to prefer
defovervalin traits