Errata

Kotlin Cookbook

Errata for Kotlin Cookbook

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Other Digital Version
Loc 5101
Example 6-14

Version: Kindle

Example is meant to demonstrate use of yeildAll, yet does not reference this function whatsoever. I suspect that:

yield(generateSequence...

Should in fact read:

yieldAll(generateSequence...

Note from the Author or Editor:
Yes, that example contains multiple errors. It should be:

val sequence = sequence {
val start = 0
yield(start)
yieldAll(1..5 step 2)
yieldAll(generateSequence(8) { it * 3 })
}

println(sequence.take(8).toList()) // [0, 1, 3, 5, 8, 24, 72, 216]

The code in the GitHub repository has been updated with this example.

Elliot West  Aug 21, 2020