Summary
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access