Answers for "kotlin for loop enumerate"

3

for loop kotlin

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)
}
Posted by: Guest on May-10-2020
0

for loop in kotlin with index

collection.forEachIndexed { index, element ->
    // ...
}
Posted by: Guest on January-07-2021

Browse Popular Code Answers by Language