Group Group Group Group Group Group Group Group Group

Errata for Swift Apprentice, 6th ed

Creating this topic for bugs, typos, and other mistakes found is Swift Apprentice, 6.0.

Hi,

Section 18.4 (Testing) has subheading “ XCTFail and XCTSkip” duplicated.

Hello,

I have Swift Apprentice 5, Is there an upgrade path to 6 ?
Or do I need to purchase it again ?

Thank you. CatzShadowy

Hello, @catzshadowy! If you owned the 5th edition, when you click on the link, it should automatically take you to the 6th edition. Is the link not working for you? Please email me at manda@razeware.com if not. Thank you!

1 Like

Thank you! I’ve passed this on to the team.

Hello, @mandafrederick Thank you !

Yes I just downloaded and updated my Swift Apprentice to v6.0 and materials.
Without problems, from the link in email I received. :blush:

Sincerely CatzShadowy

Hi,

The note under Section II, 7.12, “Using properties and methods” says that a dictionary needs to loop through all its values to compute the count, but .count in fact runs in O(1) (implementation).

Thanks!

Thank you! I’ve passed this on to our team. Cheers!

" Methods in protocols" under “Section 16. Protocols” says To provide direction as an optional argument, you’d define both versions of the method explicitly:
func turn()
func turn(_ direction: Direction)

but what do you think about defining function with optional argument? like this:
func turn(_ direction: Direction?)

thanks!

Hello! Thank you so much for the feedback. I’ll pass it off to the teams!

I found a small mistake in Ch. 2 Challenge answers available on GitHub, line 74: sa-materials/Contents.swift at editions/6.0 · raywenderlich/sa-materials · GitHub

In the book, see Ch 2.Types & Operations >>> Challenge 6

Line 74 should be: let value = tuple.1 // value = 1.5 of type Double

The challenges keep using the same constant name “tuple” - this led the author to use the incorrect “tuple.1” value. The reason I noticed this is because my Playground said the inferred type was Int, which didn’t make sense. I then realized it was an issue of naming the constants.

I think the accuracy of the answer for Challenge #2 in Ch. 5 could be improved. See lines 112-114 in https://github.com/raywenderlich/sa-materials/blob/editions/6.0/05-functions/projects/challenge/05-functions-challenges.playground/Contents.swift:

if number <= 3 {
return true
}

This has the undesirable consequence of returning “true” for a value of 1. Except, a prime number is defined as “a natural number greater than 1 that is not a product of two smaller natural numbers.” So the function should really be returning false when passing in an argument of 1.

So, I think a more accurate solution would be to change lines 105-107 to the following:

if number < 2 {
return false
}

Then lines 112-114 could be the following, so that the range with the square root is still valid for any number passed into the function:

if number == 2 || number == 3 {
return true
}

I am learning so much from the book! Thanks and keep up the great work at RW!

In section 7.14 it says “You can also use the first and last properties, which return one of the elements in the set.”

However, looking at the Swift developer documentation, while there is a first property, there is no last property for sets.

This topic was automatically closed after 166 days. New replies are no longer allowed.