Kotlin provides a rich library of filters and collection functions. In this section, we will start by looking at filters, which help to filter out the desired results from the collection, allowing us to ignore unwanted elements. We will then move on to looking at collection functions, which are functions that are specially designed for collections.
Filters and collection functions
The filter function
This is the most commonly used function in Kotlin. The filter function takes one lambda expression, which takes one variable as an input and returns the same variable as a result. The filter function applies the lambda expression and returns a list as a result. Let's create a list of integers and apply some filters:
var...