for loop kotlin
snippet in kotlin

kotlin simple for loop

user7489

val names = listOf("Jack", "John", "Tim")
for(name in names){
	println(name)
}

for loop kotlin

user1445

val array = arrayOf(1, 3, 9)
for (item in array) {
    //loops items
}
for (index in 0..array.size - 1) {
	//loops all indices
}
for (index in 0 untill array.size) {
    //loops all indices
}
for (index in array.indices) {
    //loops all indices (performs just as well as two examples above)
}

for loop kotlin

user6100

for (x in 0..10) println(x)