Creating Functions
We'll cover the following
Creating functions, and methods, in Kotlin is refreshingly different from creating methods in Java. The greater flexiblity that Kotlin offers removes unnecessary ceremony when creating functions. Let’s start with short functions, explore type inference, and then look at defining parameters and multiline functions.
KISS functions
Kotlin follows the mantra “Keep it simple, stupid”—the KISS principle—to function definitions. Small functions should be simple to write, no noise, no fluff. Here’s one of the shortest functions you can write in Kotlin, followed by a call to it.
Get hands-on with 1200+ tech skills courses.