Kotlin for loop: in、 until、 step、 downTo
fun loop1() {for (i in 0..5) {print("$i ")}println("\n1-end\n")
}fun loop2() {for (i in 0 until 5) {print("$i ")}println("\n2-end\n")
}fun loop3() {for (i in 0 until (5)) {print("$i ")}println("\n3-end\n")
}fun loop4() {for (i in 0..5 step 2) {print("$i ")}println("\n4-end\n")
}fun loop5() {for (i in 5 downTo 0) {print("$i ")}println("\n5-end\n")
}fun main(args: Array<String>) {loop1()loop2()loop3()loop4()loop5()
}
0 1 2 3 4 5
1-end0 1 2 3 4
2-end0 1 2 3 4
3-end0 2 4
4-end5 4 3 2 1 0
5-end
kotlin的for循环遍历_kotlin for遍历-CSDN博客文章浏览阅读308次。kotlin的for循环遍历。_kotlin for遍历https://blog.csdn.net/zhangphil/article/details/130730729kotlin forEachIndexed arrayListOf<String>-CSDN博客文章浏览阅读140次。Python for循环中的zip_python zip函数用于for循环_zhangphil的博客-CSDN博客。https://blog.csdn.net/zhangphil/article/details/131003571