After going through a few examples, I have to say, I fail to understand what the F-Bounded polymorphic brings.
To use the example from scala school (https://twitter.github.io/scala_school/advanced-types.html#fbounded)
They explain that they need some F-Bounded type so that the subclass can return the subtype. So they do something like this:
trait Container[A <: Container[A]] extends Ordered[A]
class MyContainer extends Container[MyContainer] {
def compare(that: MyContainer) = 0
}
But I don't see what is the gain of using this kind of type when you could use something like this:
trait Container[A] extends Ordered[A]
class MyContainer extends Container[MyContainer] {
def compare(other: MyContainer) = 0
}
Any explanation is very welcomed
Thanks