【发布时间】:2019-01-10 10:57:16
【问题描述】:
为什么不编译?
class test
{
constructor() {
var a = Date().day
this(a)
}
constructor(a:Int) {
}
}
错误是: 'test' 类型的表达式 'this' 不能作为函数调用。找不到函数'invoke()'。
建议的解决方法是添加以下内容:
private operator fun invoke(i: Int) {}
为什么?
【问题讨论】:
标签: kotlin class-constructors multiple-constructors