September 2019
Intermediate to advanced
462 pages
11h 3m
English
Since coroutines are useful for creating cooperating tasks, we can use them to create an infinite series or unbounded values and process the generated values at the same time. A function may create a value in the series and yield it to the code that is expecting the value. Upon consuming the value, the calling code can come back asking for the next value in the series. These steps can continue in tandem until either the code that produces the series exits or the caller doesn’t bother asking for another value in the series. We’ll take a look at two different functions available in Kotlin to create infinite series.
The Kotlin library has a sequence function that’s readily available for creating a series ...
Read now
Unlock full access