📜  kotlin filternot - Kotlin 代码示例

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

代码示例1
fun main() {
    val asha = Student(101, "Asha")
    val john = Student(102, "John")
    val afra = Student(103, "Afra")
    val kyle = Student(104, "Kyle")
    val studentList = listOf(asha, john, afra, kyle)
    val filteredList = studentList.filterNot { student -> 
                student.name.startsWith("K")
    }
    println(filteredList) 
}
data class Student(val id: Long, val name: String)