Page 187 (PDF page 219):
Listing 10.6 should be
class LineElement(s: String) extends ArrayElement(Array(s)) {
override val width = s.length
override val height = 1
}
It uses def instead of val which gives the following compiler error:
LineElement.scala:2: error: overriding value width in class Element of
type Int;
method width needs to be a stable, immutable value
override def width = s.length
^
LineElement.scala:3: error: overriding value height in class Element of
type Int;
method height needs to be a stable, immutable value
override def height = 1
|
Page 190 (PDF page 222):
In the implementation of the class `UniformElement',
private val line = ch.toString * width
should really be
private def line = ch.toString * width
Otherwise, the code can compile, but will throw a
java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
Tested at Debian Squeeze, with Scala version 2.7.7final
|
Page 184 (PDF page 222):
class UniformElement(
ch: Char,
override val width: Int,
override val height: Int
) extends Element {
private val line = ch.toString * width
def contents = Array.make(height, line)
}
Array does not have a make method (scala 2.10.0-RC2. I'm using ItelliJ
and this is syntax highlighted as unknown and I can't find it in the
documentation
|
Page 191 (PDF page 223):
2nd, 3rd line: Replace "We'll override demo in in ArrayElement..." by
"We'll override demo in ArrayElement...".
FIXED
|
Page 194 (PDF page 235):
class UniformElement(
ch: Char,
override val width: Int,
override val height: Int
) extends Element {
private val line = ch.toString * width
def contents = Array.make(height, line)
}
Array.make(height, line) can be replaced with
Array.fill(height)(Line)
|
|
|
|