There are not many. These two statements are equivalent:
case x :: xs => case ::(x, xs) =>
Say you want something to split the list into odds and evens, and name it ** . You can write an extractor as follows:
object ** { def unapply(xs: List[Int]) = Some(xs partition (_ % 2 == 0)) } scala> List(1,2,3) match { | case evens ** odds => println("Evens: "+evens+"\nOdds: "+odds) | } Evens: List(2) Odds: List(1, 3)
source share