Kotlin filterIndexed

fun main() {
    val numbers = listOf("zero", "one", "two", "three", "four")
    val filteredIdx = numbers.filterIndexed { index, s -> (index % 2 == 0) }
    println(filteredIdx) /* prints [zero, two, four] */
}
data class Student(val id: Long, val name: String)
Smoggy Snail