June 2017
Intermediate to advanced
400 pages
8h 44m
English
I could spend a lot of time deconstructing lambdas in Kotlin, but in the interest of "getting to the point", I will show how they are expressed in the context of RxJava. You can learn about Kotlin lambdas in depth on the Kotlin reference site (https://kotlinlang.org/docs/reference/lambdas.html).
Kotlin offers a few more ways to express lambdas than Java 8, and it also uses curly brackets { } instead of round brackets ( ) to accept lambda arguments into functions. The following is how we express an Observable chain emitting strings and then map and print their lengths:
import io.reactivex.Observable fun main(args: Array<String>) { Observable.just("Alpha", "Beta", "Gama", "Delta", "Epsilon") .map { s: String -> s.length } .subscribe ...Read now
Unlock full access