© Ted Hagos 2018
Ted HagosLearn Android Studio 3 with Kotlinhttps://doi.org/10.1007/978-1-4842-3907-0_3

3. Functions

Ted Hagos1 
(1)
Manila, National Capital Region, Philippines
 
What we’ll cover:
  • Declaring functions

  • Default parameters

  • Named parameters

  • Extension functions

  • Infix functions

  • Infix operators

Kotlin’s functions are almost the same as Java methods, although it’s closer in behavior to functions in JavaScript, because in Kotlin, functions are more than just a named collection of statements. In Kotlin, functions are first-class citizens; you can use a function wherever you could use a variable. You can pass them as parameters to other functions, and you can return functions from other functions as well. But before we can dive into that topic, we ...

Get Learn Android Studio 3 with Kotlin: Efficient Android App Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.