Sample code from chapter 32 of Programming in Scala 2nd