code |
Some code in "An Introduction to Scala" does not compile
with current Scala compilers (e.g. 2.3.1).
p7 (javac) illegal start of expression
public String mail() default = "";
should be
public String mail() default "";
p12 Automatic User-Defined Coercions
// error: method coerce is defined twice
def coerce: Float = numerator.asInstanceOf[Float] / denominator
def coerce: Double = numerator.asInstanceOf[Double] / denominator
// error: type mismatch;
// found : examples.Frac
// required: scala.Double
Console.println(Math.sqrt(Frac(1,2)) + ", " +
This came up in the newsgroup:-
http://article.gmane.org/gmane.comp.lang.scala/3238
http://article.gmane.org/gmane.comp.lang.scala/3239
http://article.gmane.org/gmane.comp.lang.scala/3240
I suspect that views made coerce obsolete and that the example should use views and thus appear later in the document. Is this correct?
p35 Obsolete use of with without extends:
object GraphTest with Application {
should be
object GraphTest extends Application {
p37 private class LoopUnlessCond escapes its defining scope
private class LoopUnlessCond(body: => Unit) {
should be
class LoopUnlessCond(body: => Unit) {
(Alternately, the return type of loop should be a public class or trait that LoopUnlessCond extends.)
p41 prefix method name with `&'
set += main // add the main function
should be
set += &main // add the main function
|