lazy { ... } 的情况。
示例:
private val x = lazy { "hello" }
fun test() {
printlin(x.value)
}
如果 lazy 变量仅通过直接访问其值的方式来使用,则建议使用快速修复:
private val x by lazy { "hello" }
fun test() {
println(x)
}
不会报告具有显式 lazy 类型的构造,例如
private val x: Lazy<String> = lazy { "hello" }
因为它们被认为是有意使用的。