【发布时间】:2019-12-22 07:39:04
【问题描述】:
例如,当我有两个 forEach lambda 时,我想返回一个特定的,例如以下示例中的 thing1,而不是 thing0。 如果我尝试以下操作,它会抱怨“在此范围内有多个标签具有这样的名称”
解释我的问题的伪代码:
thing0.forEach { _ ->
thing1.forEach { _ ->
// I'd like to return the thing1 forEach lambda, but the compiler
// issues a warning that there are multiple forEach lambdas present.
if (condition) return@forEach
}
}
【问题讨论】:
-
这个页面也许能帮上忙?它在那里给出了标记返回的所有变体。 kotlinlang.org/docs/reference/returns.html
-
干杯,伙计!做到了!
标签: kotlin jetbrains-ide