scala – 案例类扩展特征不能使用副本
发布时间:2020-12-16 18:16:54 所属栏目:安全 来源:网络整理
导读:我试试 trait Foo[A] { def copy(int: Int): A}case class Bar(int: Int) extends Foo[Bar] 但我明白了 error: class Bar needs to be abstract,since method copy in trait Foo of type (int: Int)this.Bar is not defined 由于Bar是一个案例类,它会自动定
我试试
trait Foo[A] { def copy(int: Int): A } case class Bar(int: Int) extends Foo[Bar] 但我明白了
由于Bar是一个案例类,它会自动定义具有此签名的复制方法. 为什么Foo类不满足trait Bar定义的接口? 解决方法
我引用了
Scala’s specification:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |