The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Susan Harkins (424) [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 (133) [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
asheshb (1) [Avatar] Offline
#12
On Page 158 (PDF)

This is useful when you override a function that returns a generic parameter and make it return a value of the Unit type



I think returns a generic parameter is slightly confusing. returns the generic parameter makes more sense.
Kyungwon Chun (24) [Avatar] Offline
#13
At Loc 1284 of a Kindle version,

In the subsection 'Default values and Java,'

you can annotate it with @Jvm-Overloads.

should be
you can annotate it with @JvmOverloads.
Kyungwon Chun (24) [Avatar] Offline
#14
At Loc 1522 of a Kindle version

Not an error, but a redundant space before .split.
write "12.345-6.A" .split('.', '-'), which

should be
write "12.345-6.A".split('.', '-'), which
Kyungwon Chun (24) [Avatar] Offline
#15
At loc 1954 of a kindle version,

The hyphens in the class names should be removed.

in Subscribing-User and FacebookUser.

should be
in SubscribingUser and FacebookUser.


the property in Facebook-User

should be
the property in FacebookUser
Kyungwon Chun (24) [Avatar] Offline
#16
IMG_0127.png
[ 430 KB ]
IMG_0126.png
[ 368 KB ]
I'm reading a Kindle version. A code with multiple lines of REPL example has an odd indentation in some view options of an e-book reader. I guess this is caused by the (probably justified) text alignment option. Though Kotlin is not an indentation-specific language, this odd indentation by the text alignment should be fixed.
Kyungwon Chun (24) [Avatar] Offline
#17
At loc 996

Figure 2.4. A representation of the expression Sum(Sum-Num(1), Num(2)), Num(4))

should be

Figure 2.4. A representation of the expression Sum(Sum(Num(1), Num(2)), Num(4))