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 次 |
| 最近记录: |