Mark Elston (111) [Avatar] Offline
#1
In your final example in this section you show the creation of an infinite stream using:

val naturalNumbers = sequence(0) { it + 1 }


When I run this in the REPL I get the following:

>>> val naturalNumbers = sequence(0) { it + 1 }
error: unresolved reference: sequence
val naturalNumbers = sequence(0) { it + 1 }
                     ^
error: unresolved reference: it
val naturalNumbers = sequence(0) { it + 1 }
                                   ^


When I look at the docs for Sequence in kotlin.collections I find there is no entry for sequence. If I replace sequence with Sequence I get a different error as it is trying to apply the interface as a function.

Has the sequence function been removed or do I need to do something to resolve the name?
Mark Elston (111) [Avatar] Offline
#2
OK. I just found the answer to this. Apparently the 1.0.0 release changed the name of the sequence function to generateSequence.

Something to update in the book before it is finalized.
Dmitry Jemerov (39) [Avatar] Offline
#3
Thanks for the heads up! This has already been corrected in our internal version of the text, and will be updated in the MEAP version when we submit the latest version of the text to the publisher.