いくつかの例を見た後、F-Bounded ポリモーフィックがもたらすものを理解できていないと言わざるを得ません。
scala school ( https://twitter.github.io/scala_school/advanced-types.html#fbounded )の例を使用するには
彼らは、サブクラスがサブタイプを返すことができるように、F-Bounded 型が必要であると説明しています。したがって、彼らは次のようにします。
trait Container[A <: Container[A]] extends Ordered[A]
class MyContainer extends Container[MyContainer] {
def compare(that: MyContainer) = 0
}
しかし、次のようなものを使用できる場合、この種のタイプを使用することの利点はわかりません。
trait Container[A] extends Ordered[A]
class MyContainer extends Container[MyContainer] {
def compare(other: MyContainer) = 0
}
どんな説明でも大歓迎です
ありがとう