0
我刚刚开始使用Scalaz。我试图在它的超类中为我的类型定义一个Zero。scalaz在基类中定义的零
class Base {
implicit def BaseZ: Zero[this.type] = zero(classOf[this.type].newInstance())
}
class Child extends Base
~Option(null:Child) //trying to make this produce: new Child
我发现了两个错误:
1)由于是,这产生"error: class type required but Base.this.type found"
2)如果更改的this.type第二次出现至基础(这是没有用的),我得到
类型不匹配;
发现:基本
要求:Base.this.type
谁能帮助我了解与this.type这里回事?我真的不想传递或重写一个类型参数到基地。
那么,没有办法说延伸基地的每个孩子的零应该产生一个新的孩子吗? – scalapeno
您可以尝试使用清单 – pedrofurla
如何使用清单来完成此操作? – scalapeno