【发布时间】:2020-04-11 15:13:27
【问题描述】:
代码示例:
import java.util.UUID
interface InterfaceOne<AType> {
var abcOne:AType
}
interface InterfaceTwo<AType> {
var abcTwo:AType
}
class Example<AType>: InterfaceOne<AType>, InterfaceTwo<AType> {
override var abcOne: AType // Looking for default value to not from constructor
set(value) {
field = value
//...
}
override var abcTwo: AType // Looking for default value to not from constructor
set(value) {
field = value
//...
}
fun test(uuid: AType) {
abcTwo = uuid
abcOne = default // I'm looking for C#'s default keyword equivalent in here
}
}
fun main() {
val uuid = UUID.randomUUID()
val uuid2 = UUID.randomUUID()
val interfaceOne = Example<UUID>()
interfaceOne.test(uuid)
}
您可以使用我的游乐场进行测试! Click here.
【问题讨论】: