type Entity =
abstract member newEntity: Entity
abstract member clearEntity : Entity
abstract member lastEntity : Entity
abstract member loadData: Entity
abstract member saveData: Entity -> unit
abstract member deleteData: Entity -> unit
有什么办法可以避免重复写实体词?
type Entity =
type T = Entity
abstract member newEntity: T
abstract member clearEntity : T
abstract member lastEntity : T
abstract member loadData: T
abstract member saveData: T -> unit
abstract member deleteData: T -> unit
我想要这样的实现,Scala应该能够做到
答案 0 :(得分:6)
您不能将类型声明放在另一个内部。您可以做的是进行相互递归的类型声明:
type Entity =
abstract member newEntity: T
abstract member clearEntity : T
abstract member lastEntity : T
abstract member loadData: T
abstract member saveData: T -> unit
abstract member deleteData: T -> unit
and T = Entity