The find function that we've seen is contained in the Collections.kt file from the Kotlin standard library. This file contains a lot of extension functions that bring a functional approach to Kotlin and extend the functionality of Java's collection, in order to simplify work with them.
A collections is a hierarchy of classes and interfaces that are used to store and manipulate a group of objects.
The most common functions from the Collections.kt file are as follows:
- filter: This returns a new list that contains elements that only matched a passed predicate
- find: This returns an element that matched a passed predicate
- forEach: This performs an approved action on each element
- map: This returns a new list, where each element was transformed according to the passed function
All of these are referred to as higher-order functions.