Pau*_*per 5 inheritance scala traits
我试试
trait Foo[A] {
def copy(int: Int): A
}
case class Bar(int: Int) extends Foo[Bar]
Run Code Online (Sandbox Code Playgroud)
但我明白了
错误:类Bar需要是抽象的,因为类型为(int:Int)的trait Foo中的方法复制this.Bar未定义
由于Bar
是一个案例类,它会自动定义一个copy
具有该签名的方法.
为什么Foo
类不满足特征定义的接口Bar
?
归档时间: |
|
查看次数: |
603 次 |
最近记录: |