Errata Confirmed in 3rd Edition

Here are the confirmed errata for the 3rd edition’s first printing.
This post will be updated as errata are found.
Feel free to reply to this thread with any that you feel should be included.

Sets

  • p120: The penultimate paragraph begins “You can also go the other way, creating a set from an array using…”. This should read the other way around, “You can also go the other way, creating an array from a set using…”

Generics

  • Listing 21.6 & Listing 21.8: Both of these listings erroneously refer to the passed-in function as f, rather than its actual name, txform. In both listings, f(item) should be txform(item).

There’s another error in Sets: “You have arrays. No problem! Create two new arrays by initializing them with your sets:” should be “You have arrays. No problem! Create two new sets by initializing them with your arrays:” (I’m using the ebook so I don’t have page numbers.)

That’s on page 119, just before listing 11.11.

1 Like

Nice one (i`m about joke)

I think I found a error as well. In Chapter 6, Loops, between Listing 6.1 and Figure 6.1, the 5th paragraph reads:
“Notice that i is not declared to be of the Int type. It could be, as in for i: Int in 1…5, but an explicit type declaration is not necessary. The type of i is inferred from its context (as is the let). In this example, i is inferred to be of type Int because the specified range contains integers.”

The let command is not inferred, the var command is inferred, as i is a variable, not a constant. I also tested by placing it in the for-in Loop, and got the following error:
“error: ‘let’ pattern cannot appear nested in an already immutable context
for let i in 1…5 {”

@lotsevenk

The two paragraphs before the paragraph that you quoted read as follows (bold text is mine):

The for keyword signals that you are writing a loop. You next declare an iterator called i that represents the current iteration of the loop. The iterator is constant within the body of the loop and only exists here; it is also managed for you by the compiler.

In the first iteration of the loop, its value is the first value in the range of the loop. Because you used ... to create an inclusive range of 1 through 5, the first value of i is 1. In the second iteration, the value of i is 2, and so on. You can think of i as being replaced with a new constant set to the next value in the range at the beginning of each iteration.

I think what is meant here is that i is treated as a constant by the loop when it executes. So that’s probably what is meant by "as is the let". It means that i is a constant, so it’s as if it was created using the let keyword rather than the var keyword.

I think that it would be natural to assume that i is a variable rather than a constant because we think of i as changing each time the loop runs. And we all know that normally constants cannot change but variables can. But I suspect that the compiler implements things in a way that the loop runs like we have come to expect, despite i being treated as a constant.

I’m making some guesses here, but that is my interpretation based on the two paragraphs I quoted.