I checked the tutorial found at http://www.codecommit.com/blog/scala/scala-for-java-refugees-part-4
This tutorial is from jan. 2008, I see, but I'm using Scala 2.8.0 if that matters.
class Color(val red:Int, val green:Int, val blue:Int) case class Red(r:Int) extends Color(r, 0, 0) case class Green(g:Int) extends Color(0, g, 0) case class Blue(b:Int) extends Color(0, 0, b) def printColor(c:Color) = c match { case Red(v) => println("Red: " + v) case Green(v) => println("Green: " + v) case Blue(v) => println("Blue: " + v) case col:Color => { print("R: " + col.red + ", ") print("G: " + col.green + ", ") println("B: " + col.blue) } case null => println("Invalid color") }
When entering this into the interpreter, it produces
An exception is thrown in the main thread java.lang.IndexOutOfBoundsException in scala.collection.LinearSeqOptimized $ class.apply (LinearSeqOptimized.scala: 53) in scala.collection.immutable.List.apply (List.scala: 45)
plus 185 more trace lines, and the translator exits.
What does this error message mean, and can someone tell me what is wrong with the code above?
source share