Errata

Head First Kotlin

Errata for Head First Kotlin

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
PDF
Page 17
bottom code example, 1st comment

Original:
while (x > 3) {
//The loop code will run as x is greater than 4

Problem:
Condition tests if x is greater than 3, not 4 as mentioned in comment.

Suggested fix:
Change comment to:
//The loop code will run as x is greater than 3

Jørgen Lang  Feb 25, 2019  Jan 22, 2021
PDF
Page 52 and 55
Code A and B

The code for A and B each feature a line that includes a semicolon. These semicolons are redundant, and should be removed. The line:
var x = 0;
should be:
var x = 0
and the line:
var firemanNo = 0;
should be:
var firemanNo = 0

Dawn Griffiths
Dawn Griffiths
 
Mar 05, 2019  Jan 22, 2021
Printed
Page 57
variables - objects

can the indexing be clarrified please?

Iif a val array can be updated, then the number at that index is altered and my outcome of the values at the index and not the same as given on page 57.

If they are not updated in the in original array and that is the constant references my outcome is still not the same. Can you explain in detail how you get your outcome?

Thanks

Note from the Author or Editor:
The "Match each variable to its object" annotation can be removed.

The following annotations need to go against the relevant lines of code to clarify the solution:
x[3] = x[2] "x[3] is now 2"
x[4] = x[0] "x[4] is now 0"
x[2] = x[1] "x[2] is now 1"
x[1] = x[0] "x[1] is now 0"
x[0] = x[1] "x[1] is 0, so x[0] is still 0"
x[4] = x[3] "x[3] is 2, so x[4] is now 2"
x[3] = x[2] "x[2] is 1, so x[3] is now 1"
x[2] = x[4] "x[4] is 2, so x[2] is now 2"

Anonymous  Nov 05, 2020  Jan 22, 2021
PDF
Page 65
3rd heading

Original: "You can pass variables to a function so long as the variable type matches the parameter type"

Readers might get the impression that *only* variables can be passed to a function. This could be misleading. "argument" is a more general term that also includes "plain" values.

Suggestion: Use "arguments/type of argument“ instead of "variable".

Note from the Author or Editor:
Change the third heading to:
You can pass arguments to a function so long as the argument type matches the parameter type

Jørgen Lang  Feb 27, 2019  Jan 22, 2021
PDF
Page 82
heading

Heading reads "More powerful boolean expressions (continued)", but there is no previous heading of that name.

Suggested fix: Remove "(continued)"

Note from the Author or Editor:
We don't need the main heading on this page, as it's really a continuation of the previous page. The entire heading "More powerful boolean expressions (continued)" can be removed.

Jørgen Lang  Feb 18, 2019  Jan 22, 2021
PDF
Page 109
second last code annotation

Original: "Creates a Duck variable, and assigns it a reference to a Duck object."

Should be "Creates a myDuck variable, and assigns it a reference to a Duck object." to match the code example on the left.

Suggested fix: change "Duck variable" to "myDuck variable"

Note from the Author or Editor:
For extra clarification, the last but one annotation on page 109 can be changed to: Creates a Duck variable named myDuck, and assigns it a reference to a Duck object.

Jørgen Lang  Feb 20, 2019  Jan 22, 2021
PDF
Page 126
4th paragraph 1st sentence

Original: "Each animal subclass inherits […] from the Animal subclass."

Suggested fix: "Each animal subclass inherits […] Animal **super** class."

Note from the Author or Editor:
The first sentence under the "...and different function implementations" heading should be: Each animal subclass inherits functions named makeNoise, eat, roam and sleep from the Animal superclass.

Jørgen Lang  Feb 22, 2019  Jan 22, 2021
PDF
Page 159
3rd para, 1st sentence

Original: "When we created the Animal class, we decided to instantiate the image, food and habitat properties …"

Suggested fix: "When we created the Animal class, we decided to *initialize* the image, food and habitat properties "

Jørgen Lang  Mar 06, 2019  Jan 22, 2021
PDF
Page 224
2nd para, last sentence + annotation of following code example

Location:
"The following code, for example, checks that w’s value is not null, and then calls the object’s eat function:"

Problem:
Missing parentheses for 'eat()' function in text.

Suggested fix:
Add parentheses after 'eat' for consistency and to avoid confusion.

Jørgen Lang  Apr 08, 2019  Jan 22, 2021
Page 234
3

"If w and hunger are is not null," should read, "If w and hunger are not null."

Jeff Solodky  Mar 07, 2021 
Printed
Page 259
above the last paragraph

Hi! On page 259 there is an example that says:
"The following code, for example, copies mShopping, and assigns the copy to a new variable named shoppingSnapshot"

The Variable called shoppingSnapshot is wrong because the following example is:

val shoppingCopy = mShopping.toList()

So the variable should be called shoppingCopy instead shoppingSnapshot.

Note from the Author or Editor:
shoppingSnapshot in the body text needs to be changed to shoppingCopy.

Laura  Dec 03, 2020  Jan 22, 2021
PDF
Page 315
2nd last paragraph, 1st sentence

Context: Using "in".

Original: "…whether you want the generic subtype to accept a generic supertype in every situation…"

Question: Is it really the subtype that accepts another type?

It seems that a generic supertype could be used *instead of* a generic generic subtype.

Note from the Author or Editor:
Change the wording to "...whether you want the generic subtype parameter to accept a supertype in every situation"

Jørgen Lang  Apr 24, 2019  Jan 22, 2021
PDF
Page 339
code example, comment

Original:
fun convert(x: Double,
converter: (Double) -> Double ) : Double {
//Code to convert the Int
}

Suggested fix:
//Code to convert the Double

Jørgen Lang  May 07, 2019  Jan 22, 2021
PDF
Page 341
1st para

Text:
"The following things happen when you call the convert function using the code:"

Missing formatting for "convert"

Suggested fix:
Format "convert" as code.

Jørgen Lang  May 07, 2019  Jan 22, 2021
PDF
Page 398
4th para, 2nd sentence + screenshot

The option name has changed slightly. It is now "Kotlin/JVM".
Also, by default, the option "Java" is selected. This should be deselected.

Note from the Author or Editor:
Update the text to say "To do this, create a new project, select the Gradle option, check the Kotlin (Java) option, and make sure all the other options for additional libraries and frameworks are unchecked."

Jørgen Lang  May 21, 2019  Jan 22, 2021
PDF
Page 403
1st para, 2nd sentence

Original: "To do this, open build.gradle, and update the dependencies section like so:"

Problem: Files in IDEA are usually open by simply clicking on them (contents is then shown in main window). build.gradle needs to be double clicked to show its contents.

Suggestion: Update text to say: "To do this, open build.gradle with a double click on the file name, and update the dependencies section like so:"

System: macOS 10.12.6 (Sierra), IntelliJ IDEA 2019.1

Jørgen Lang  May 20, 2019  Jan 22, 2021
PDF
Page 428
3rd para, last sentence

Original: "[…] the object implements MouseAdapter, and overrides its mouseClicked and mouseEntered function"

Problem: Example uses "mouseReleased" insted.

Suggestion: Change "mouseEntered" to "mouseReleased" in the text.

Note from the Author or Editor:
Change mouseEntered in the body text to mouseReleased.

Jørgen Lang  May 26, 2019  Jan 22, 2021