确实,let
函数在 Kotlin 中被广泛使用,特别是在处理可空类型或者需要在对象上执行一系列操作后返回结果的场景中非常有用。
- let 函数的源代码
/** * Calls the specified function [block] with `this` value as its argument and returns its result. * * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#let). */ @kotlin.internal.InlineOnly public inline fun <T