filterNotTo

inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C

Appends all elements not matching the given predicate to the given destination.

The operation is terminal.

Samples

import samples.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7)
val evenNumbers = mutableListOf<Int>()
val notMultiplesOf3 = mutableListOf<Int>()

assertPrints(evenNumbers, "[]")

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

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