为什么kotlin中不支持挂起运算符fun getValue?
为什么下面的签名会出现为什么kotlin中不支持挂起运算符fun getValue?,kotlin,kotlin-coroutines,Kotlin,Kotlin Coroutines,为什么下面的签名会出现不受支持的[suspend operator“getValue”]编译错误 suspend operator fun getValue(thisRef: Any?, property: KProperty<*>): T suspend操作符fun getValue(thisRef:Any?,属性:KProperty):T 这是因为任何技术限制吗?getValue操作符用于实现val的getter,并且没有挂起val之类的东西——只有正常的val 一个susp
不受支持的[suspend operator“getValue”]
编译错误
suspend operator fun getValue(thisRef: Any?, property: KProperty<*>): T
suspend操作符fun getValue(thisRef:Any?,属性:KProperty):T
这是因为任何技术限制吗?getValue操作符用于实现
val
的getter,并且没有挂起val
之类的东西——只有正常的val
一个
suspend fun
不能直接从一个普通函数调用,比如getter的实现——因此这个getValue
不能用于它的预期目的。Kotlin警告您,在尝试创建suspend操作符fun getValue
时出现编译错误,getValue
操作符用于实现val
的getter,而不存在suspend val
这类东西——只有正常的val
一个suspend fun
不能直接从一个普通函数调用,比如getter的实现——因此这个getValue
不能用于它的预期目的。Kotlin警告您,在尝试创建挂起运算符fun getValue
时会出现编译错误