July 2018
Intermediate to advanced
266 pages
7h 11m
English
Suspending sequences are quite different from suspending iterators, so let's take a look at some of the characteristics of suspending sequences:
In order to create a suspending sequence, we will use the builder buildSequence(). This builder takes a suspending lambda and returns a Sequence<T>, where T can be inferred by the elements that are yielded, as for example the following:
val sequence = buildSequence { yield(1)}
This will make the sequence a Sequence<Int>. But, similar to iterators, you can always specify a T as long as the values that are yielded are compliant: ...
Read now
Unlock full access