Top-level functions
In many of the examples, we've been looking at functions that are not enclosed within any type of class. This is a key feature of functions in Kotlin. Functions may be defined as independent units of execution inside any Kotlin file. Functions defined like this are known as top-level functions and may be fully available to both Kotlin and Java code, depending on their visibility. We'll dive further into top-level functions later in this chapter.
In this section, we introduced Kotlin functions and began exploring how we can work with functions in a variety of ways including as variables, properties, and function arguments. In the next section, we'll dive deeper into how to define Kotlin functions that reduce boilerplate ...
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