October 2019
Intermediate to advanced
434 pages
11h 54m
English
Is Kotlin a functional programming language?
It can be. Kotlin supports first-class functions and higher-order functions, and has a large standard library filled with useful functions that can be chained together to write highly functional code. Let's look at a few examples of functional code in Kotlin.
In the following snippet, you can see how Kotlin allows you to store a function as a variable:
fun main(args: Array<String>) { // we can store a function as a variable val stringFilter:(String) -> Boolean = { string -> string.length > 3 }}
This variable can then be used to invoke the function, or it can be passed to another function as an argument.
Here's an example of a higher-order function taken from the ...
Read now
Unlock full access