2 Functional programming in Kotlin: An overview
In this chapter
- Declaring and initializing fields and variables
- Kotlin’s classes and interfaces
- Kotlin’s two types of collections
- Functions (and control structures)
- Handling nulls
In this chapter, I provide a quick overview of the Kotlin language. I assume that you know a bit (at least) of Java, so I stress the differences between the two languages. The intent is not to teach you Kotlin. You’ll find other books for this. If you need an in-depth coverage of Kotlin, I recommend you read Dmitry Jemerov and Svetlana Isakova’s Kotlin in Action (Manning, 2017).
This chapter gives you a first glimpse of what to expect from Kotlin. Don’t try to remember everything. Look at some of the astounding features of the Kotlin language and see how it differs from Java. In the following chapters, I come back to each feature, used in a safe programming context. In the rest of this chapter, I give you an overview of the most important benefits of using Kotlin. This presentation is certainly not exhaustive, and you’ll discover additional benefits in the rest of the book.
2.1 Fields and variables in Kotlin
val name: String = "Mickey"
Note the differences with Java: