Scala pattern matching on sequences other than Lists
问题 I have the following code which recursively operates on each element within a List def doMatch(list: List[Int]): Unit = list match { case last :: Nil => println("Final element.") case head :: tail => println("Recursing..."); doMatch(tail) } Now, ignoring that this functionality is available through filter() and foreach() , this works just fine. However, if I try to change it to accept any Seq[Int] , I run into problems: Seq doesn't have ::, but it does have +:, which as I understand is