break跳出循环
var list = arrayListOf<Int>(1,2,3,4,5)
run outSide@{
list.forEach {
if (it > 3) return@outSide
println("$it")
}
}
continue跳过
var list = arrayListOf<Int>(1,2,3,4,5)
list.forEach constituting@ {
if (it == 3) return@constituting
println("$it")
}
网友评论