Kotlin filter 根据条件过滤数组

fun main() {
    val numbers1 = listOf<Int>(213, 4, 534, 646, 757, 8, 97, 9);
    val numbers2 = listOf<Int>(214, 5, 535, 647, 758, 9, 98, 10);
    val numbers3 = listOf(numbers1, numbers2);
    val res = numbers3.flatMap {
        it
    }.filter {
        it < 10
    }
    println(res)

}

猜你喜欢

转载自blog.csdn.net/mp624183768/article/details/124133262