code |
/* From ScalaByExample.pdf dated November 23, 2006
distributed with Scala compiler 2.3.0 */
// page 9
Array.concat(
sort(xs filter (pivot >)) // needs a trailing comma
xs filter (pivot ==),
sort(xs filter (pivot <)))
}
// page 14
// Actor is used without an import. Solution:-
// import scala.actors.Actor
// page 15
var maxBidder: Actor = _
// error: local variables must be initialized
// Alternatives include
// var maxBidder: Actor = null // rest of function not affected
// var maxBidder: Option[Actor] = None // uses of maxBidder need updating
receiveWithin ((closing.getTime() - new Date().getTime())) {
// error: not found: value receiveWithin
// Solution ???
// page 23
/*
Every definition in a block must be followed by a semicolon, which separates this
definition from subsequent definitions or the result expression. However, a semicolon
is inserted implicitly if the definition ends in a right brace and is followed by
a new line. Therefore, the following are all legal:
*/
// No longer accurate: ‘;’ is no longer mandatory if
// the definition is followed by a new line.
def f(x) = x + 1; /* ‘;’ mandatory */
// error: ':' expected but ')' found.
// def f(x: double) = x + 1
// I haven't tested further
|