kotlin forEach循環(huán)return/break
fun main(args: Array<String>) {
var a = mutableListOf("0", "1", "2", "3", "4")
var b = mutableListOf<String>()
a.forEachIndexed { index, s ->
if (index > 2) {
return@forEachIndexed
}
b.add(s)
}
println(b)
b.clear()
a.forEachIndexed mybreak@{ index, s ->
if (index > 3) {
return@mybreak
}
b.add(s)
}
println(b)
}
?文章來源地址http://www.zghlxwxcb.cn/news/detail-562911.html
[0, 1, 2]
[0, 1, 2, 3]
?
?
kotlin forEachIndexed arrayListOf<String>_zhangphil的博客-CSDN博客Python for循環(huán)中的zip_python zip函數(shù)用于for循環(huán)_zhangphil的博客-CSDN博客。https://blog.csdn.net/zhangphil/article/details/131003571文章來源:http://www.zghlxwxcb.cn/news/detail-562911.html
?
到了這里,關(guān)于kotlin forEach循環(huán)return/break的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!