Susan Harkins (274) [Avatar] Offline
#1
Please post errors in the published version of Kotlin in Action here. If necessary, we'll publish a comprehensive list for everyone's convenience. Thank you!

Susan Harkins
Errata Editor
Manning Publications
438572 (1) [Avatar] Offline
#2
https://forums.manning.com/posts/list/39565.page

Could you please answer whether it is an errata?
474431 (2) [Avatar] Offline
#3
Page 140:
Now that you’ve seen the Kotlin way to perform “if not-null” checks, let’s talk about the Kotlin safe version of instanceof checks: the safe-cast operator that often appears together with safe calls and Elvis operators.

The word "of" right before "instanceof" should have regular font, not fixed-width font as "instanceof".
474431 (2) [Avatar] Offline
#4
deleted
ewilligers (31) [Avatar] Offline
#5
Listing 3.3. Declaring joinToString() as a top-level function
in
3.2.3 Getting rid of static utility classes: top-level functions and properties

The code appears twice:-

package strings
fun joinToString(...): String { ... }

package strings

fun joinToString(...): String { ... }
ewilligers (31) [Avatar] Offline
#6
6.1.9 Extensions for nullable types
mentions "isEmptyOrNull and isBlankOrNull".

isNullOrBlank and isNullOrEmpty are the correct names.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/is-null-or-blank.html
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/is-null-or-empty.html
471252 (3) [Avatar] Offline
#7
Page 48, the second line from bottom:

joinToString(list, suffix = ";", prefix = "# ")

"suffix" should be "postfix"
Mark Elston (113) [Avatar] Offline
#8
Figure 9.8 shows Animal inheriting from Cat. This should be reversed.
Frank Schmitt (5) [Avatar] Offline
#9
Probably not exactly an erratum, but listing 7.11 contains this:

operator fun Rectangle.contains(p: Point): Boolean {
    return p.x in upperLeft.x until lowerRight.x &&
           p.y in upperLeft.y until lowerRight.y
}

>>> val rect = Rectangle(Point(10, 20), Point(50, 50))
>>> println(Point(20, 30) in rect)
true
>>> println(Point(5, 5) in rect)
false


I initially thought that the condition for y (
p.y in upperLeft.y until lowerRight.y
) was wrong (it should be the other way round).

But now I guess that the example assumes a coordinate system where the origin is in the upper left corner and x increases from left to right and y from top to bottom. As far as I can tell, this is never explained (but it should be at least mentioned).
521344 (1) [Avatar] Offline
#10
Code error in 5.2.1 :

val maxAge = people.maxBy(Person::age).age


The maxBy funtion returns a nullable object, code shoud be replaced by

val maxAge = people.maxBy(Person::age)!!.age
439501 (1) [Avatar] Offline
#11
Hi,

There seems to be a missing curly brace at the end of line 8 in Listing 3.4 (page 54) when starting the for loop.

Kind regards