📜  kotlin filterindexed - Kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:34.375000             🧑  作者: Mango

代码示例1
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)