Scala List filterNot() method with example
Last Updated :
26 Jul, 2019
The filterNot() method is utilized to select all elements of the list which does not satisfies a stated predicate.
Method Definition: def filterNot(p: (A) => Boolean): List[A]
Return Type: It returns a new list consisting all the elements of the list which does not satisfies the given predicate.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 5 , 12 , 3 , 13 )
val result = m 1 .filterNot( _ < 10 )
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 5 , 12 , 3 , 13 )
val result = m 1 .filterNot( _ < 3 )
println(result)
}
}
|
Output:
List(5, 12, 3, 13)
Share your thoughts in the comments
Please Login to comment...