June 2017
Intermediate to advanced
400 pages
8h 44m
English
When you are doing RxJava work in Kotlin, something that is immensely helpful is creating extension functions. We will cover specifically how later, but here is a nonreactive example.
Say we want to add a convenient function to LocalDate in order to quickly compute the number of days to another LocalDate. Rather than invoking verbose helper classes to do this task repeatedly, we can quickly add an extension function to LocalDate called numberOfDaysTo(), as shown here. This does not extend LocalDate but rather lets the compiler resolve it as a static method:
import java.time.LocalDate import java.time.temporal.ChronoUnit fun main(args: Array<String>) { val startDate = LocalDate.of(2017,5,1) val endDate = LocalDate.of(2017,5,11) ...Read now
Unlock full access