Page 405 (PDF page 436):
The reason this works is that since printBookList ’s pa-
rameter type is Book , the body of the printBookList method will only be
allowed to pass a Book into the function.
^^^
printBookList is a method and it doesn't have type parameters, what was
probably meant is that "val books: Set[Book]"'s parameter type is Book,
hence "book" in "info(book)" has a type Book.
FIXED in 3ed 4th printing
|
Page 426 (PDF page 456):
The problem reported about p.438 in 2nd edition regarding "bessy eat (new
Grass)" (see
https://booksites.artima.com/programming_in_scala_2ed/errata?c=20 ) is
still found in 3rd edition. I am reading the book on safari.oreilly.com
and hence page number may not be 418 but it's definitely 3rd edition.
[Text from previous report:
It makes sense that I cannot feed the Cow 'bessy' a new Fish, but I
cannot feed bessy new Grass either. From the text it seems that I should
be able to. Why else point out that bessy cannot eat Fish if it can't
eat Grass either?
scala> class Food
defined class Food
scala> abstract class Animal {
| type SuitableFood <: Food
| def eat(food: SuitableFood)
| }
defined class Animal
scala> class Grass extends Food
defined class Grass
scala> class Cow extends Animal {
| type SuitableFood = Grass
| override def eat(food: Grass) {}
| }
defined class Cow
scala> class Fish extends Food
defined class Fish
scala> val bessy: Animal = new Cow
bessy: Animal = Cow@4bd767
scala> bessy eat (new Fish)
<console>:12: error: type mismatch;
found : Fish
required: bessy.SuitableFood
bessy eat (new Fish)
^
scala> bessy eat (new Grass)
<console>:11: error: type mismatch;
found : Grass
required: bessy.SuitableFood
bessy eat (new Grass)
^
]
|
Page 425 (PDF page 463):
Terrible mistakes! Two BuggyAnimals came out of nowhere!
---
True! This mistake has been fixed in 5ed. The animals are still buggy in
the same way, but you no longer see a source file name.
|
Page 438 (PDF page 476):
"The toString method in class Currency..." should be "The toString
method in class CurrencyZone..."
"To achieve this, you could implement Currency's..." should be "To
achieve this, you could implement CurrencyZone's..."
---
Fixed in 5ed. The correct class name is actually AbstractCurrency.
|
Page 439 (PDF page 477):
"...method, from, to class Currency..." should be "...method, from, to
class AbstractCurrency..."
I guess those that I mentioned for page 438 should also be
AbstractCurrency instead of CurrencyZone.
---
Fixed in 5ed. Tnx!
|
Page 442 (PDF page 480):
Looks like Val CurrencyUnit: Currency at the bottom of the listing was an
after-thought to add, when it wouldn't compile without it. Works just as
good if it is placed by the top with the other CurrencyZone declarations.
---
I suppose so. Does look kind of funny. And it looks maybe even worse in
indentation style in Scala 3 if there's no end. I made a TODO to rework
this. Going to add an end, but may move that up, which is what I'd
probably do in my own source code. Come to think of it, this *is* my own
source code!
|