我有两个班Entity,并Account 为
abstract class Entity(
var id: String? = null,
var created: Date? = Date()) {
constructor(entity: Entity?) : this() {
fromEntity(entity)
}
fun fromEntity(entity: Entity?): Entity {
id = entity?.id
created = entity?.created
return this;
}
}
Run Code Online (Sandbox Code Playgroud)
和
data class Account(
var name: String? = null,
var accountFlags: Int? = null
) : Entity() {
constructor(entity: Entity) : this() {
super(entity)
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我错误
超级不是表达式,它只能用在点'左'的左侧.
为什么我不能这样做?
以下将传递编译错误,但我不确定它是否正确.
constructor(entity: Entity) : this() {
super.fromEntity(entity)
}
Run Code Online (Sandbox Code Playgroud) kotlin ×1