The Artima Developer Community


Errata for Programming in Scala, 2nd Edition
Chapter 30: Object Equality
Return to errata index.

Page 654 (PDF page 687):
The following example is indeed not perfect.  It's single parameter
should be named "that" and not "other" because it is referred to as
"that" in most of the body.

// A better definition, but still not perfect
override def equals(other: Any) = other match {
  case that: Point => ...
}
Page 664 (PDF page 697):
Listing 30.2
------------------
case that: ColoredPoint =>
  (that canEqual this) && 
   super.equals(that) && ...
------------------

The "that canEqual this" part is redundant, because the same check is
done inside "super.equals(that)" already.
Page 672 (PDF page 705):
The sentence "The only exception to this requirement is for final classes
that redefine the equals method inherited from AnyRef." seems
contradictory to the initial sentence of rule #1. 

Sorry if I have misunderstood the rule.

Page number: Book type: Paperback book PDF eBook
Book version: (Or build date. Found on back of title page.)
Your feedback:
Your name: (optional)
Your email address: (optional) (will not be published)

Copyright © 2024 Artima, Inc. All rights reserved.