The title pretty much sums up my question.
The deprecation and removal of case class inheritance is a pretty new one, and I wonder which things got removed/substantially changed before that. I remember something about val
in for loops and a different name for object
as well as some requires
keyword.
I would love to see code examples of how things were used/how they were replaced later, with an actual version when it happened and with a rationale why!
PS: One item per answer seems to be a good idea!
Case class inheritance was a short-lived feature: It was introduced in 2.7, deprecated in 2.8/2.9 and finally removed in 2.10.
Example:
case class Foo(a: Int, b: Int)
case class Bar extends Foo(42, 43)
The problem was that the automatically supplied equality implementations didn't really work in the face of inheritance, therefore this feature was removed.
Removing case class inheritance has also a good effect:
It will allow supplying better typed product***
methods by inheriting the concrete ProductN
trait:
val f = Foo(1,2).productIterator
f: Iterator[Any] = non-empty iterator // < 2.10
f: Iterator[Int] = non-empty iterator // 2.10 with -Xexperimental
It was possible in Scala 2.7 to declare things of type int
(no capital "I"). Since Scala does not support the idea of primitive values and tries to be as consistent with everything as far as it can, this "feature" is deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With