How can I suppress the \"match is not exhaustive!\" warning in the following Scala code?
val l = \"1\" :: \"2\" :: Nil l.sliding(2).foreach{case List(a,b) =&
Since your sliding(2) can possibly return one last list with only one element in it, you should also test it:
sliding(2)
l sliding(2) foreach { case a::b::Nil => println("two elements: " + a + b) case l => println("one last element" + l.head) }