Page 646 (PDF page 680):
In a simple program that chooses a database at runtime, even though we
choose a database based on the input parameter, we later nonchalantly
discard that choice and hard wire to the "SimpleDatabase":
object GotApples {
def main(args: Array[String]) {
val db: Database =
if(args(0) == "student")
StudentDatabase
else
SimpleDatabase
object browser extends Browser {
val database = db
}
val apple = SimpleDatabase.foodNamed("Apple").get
^
for (recipe <- browser.recipesUsing(apple))
println(recipe)
}
}
The marked line should be:
val apple = db.foodNamed("Apple").get
|