@kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block(this)
}
Run Code Online (Sandbox Code Playgroud)
并具有如下功能:
fun getType() : String? {
val type = mContent.let {
if (!TextUtils.isEmpty(it) && it == "TYPE_1") {
return "TYPE_A" . //where it returns to, as the result of the let{}, or as return value to exit the fun getType()?
}
else {
return it
}
}
if (type == "TYPE_A") {
return getType_A()
}
return type
}
Run Code Online (Sandbox Code Playgroud)
let go{} 中块内的 return 在哪里,退出fun getType()或只是从 中返回let{}?
| 归档时间: |
|
| 查看次数: |
7583 次 |
| 最近记录: |