Spec-Zone.ru › Kotlin 1.8

filterNotTo

kotlin-stdlib / kotlin.text / filterNotTo
Требования к платформе и версии: JVM (1.0), JS (1.0), Native (1.0)
inline fun <C : Appendable> CharSequence.filterNotTo(
    destination: C, 
    predicate: (Char) -> Boolean
): C

Добавляет все символы, не соответствующие заданному предикату, в указанное назначение.

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7)
val evenNumbers = mutableListOf<Int>()
val notMultiplesOf3 = mutableListOf<Int>()

println(evenNumbers) // []

numbers.filterTo(evenNumbers) { it % 2 == 0 }
numbers.filterNotTo(notMultiplesOf3) { number -> number % 3 == 0 }

println(evenNumbers) // [2, 4, 6]
println(notMultiplesOf3) // [1, 2, 4, 5, 7]
//sampleEnd
}

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/filter-not-to.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API