Page 411 (PDF page 447):
Minor quibble. Book code gives this
trait Abstract {
type T
def transform(x: T): T
val initial: T
var current: T
}
and a class instantion of this
class Concrete extends Abstract {
type T = String
def transform(x: String) = x + x
val initial = "hi"
var current = initial
}
Note this in the trait
def transform(x: T): T
is given as this in the concrete instatiation
def transform(x: String) = x + x
whereas logically (I think) it should minimise any changes to the
concrete and rely directly on the type alias, hence the above should be
def transform(x: T) = x + x
I've tested it and it compiles.
|