The filterNot function

filterNot is the opposite of the filter function. It takes a lambda expression and returns a new list. We can write a filter that can filter out odd numbers as follows:

newList = numbers.filterNot { it % 2 == 0 }
println("Filter out Odd numbers")
println(newList)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.252.204