Functions are an important feature within Kotlin, and are considered first-class citizens of the language. Kotlin functions can be defined outside of any enclosing class as top-level functions, and can be passed to, and returned from, other functions. These traits make functional programming much more accessible within Kotlin than in other JVM languages. Additionally, functions in Kotlin reduce boilerplate and increase flexibility by providing features such as default parameter values and named arguments, which allow us to reduce the number of overloaded functions we must define.
We can also define a number of different types of functions depending on our current use cases. Extension functions allow us to modify or extend classes and APIs that we may not control, and enable us to decouple low-level components from other helper functions. Top-level functions reduce the...