filterNot

fun <T> Sequence<T>.filterNot(predicate: (T) -> Boolean): Sequence<T>(source)

Returns a sequence containing all elements not matching the given predicate.

The operation is intermediate and stateless.

Since Kotlin

1.0

Samples

import kotlin.test.*

fun main() { 
   //sampleStart 
   val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7)
val evenNumbers = numbers.filter { it % 2 == 0 }
val notMultiplesOf3 = numbers.filterNot { number -> number % 3 == 0 }

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