Kotlin中let,with,apply,run,also的区别
Posted xiaohuanqi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kotlin中let,with,apply,run,also的区别相关的知识,希望对你有一定的参考价值。
//let apply with
senoirManager.let
it.drive()
// println(this) this表示 该类的this指针 it表示该对象
println(it)
val applyResult = senoirManager.apply
this.drive()
//apply返回的 是该对象
println("applyResult:$applyResult")
val withResult = with(senoirManager)
this.drive()
//with 返回的是最后一行的值得
100
println("withResult:$withResult")
一张图 说明之间的区别
以上是关于Kotlin中let,with,apply,run,also的区别的主要内容,如果未能解决你的问题,请参考以下文章